diff --git a/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp b/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp deleted file mode 100644 index b45d3fbc13a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp +++ /dev/null @@ -1,331 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Threading; -using namespace System::Collections::Generic; -using namespace System::Text; - -generic public ref class SafeQueue -{ -private: - // - // - // A queue that is protected by Monitor. - Queue^ m_inputQueue; - // - -public: - SafeQueue() - { - m_inputQueue = gcnew Queue(); - }; - - // Lock the queue and add an element. - void Enqueue(T qValue) - { - // Request the lock, and block until it is obtained. - Monitor::Enter(m_inputQueue); - try - { - // When the lock is obtained, add an element. - m_inputQueue->Enqueue(qValue); - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - }; - // - - // - // Try to add an element to the queue: Add the element to the queue - // only if the lock is immediately available. - bool TryEnqueue(T qValue) - { - // Request the lock. - if (Monitor::TryEnter(m_inputQueue)) - { - try - { - m_inputQueue->Enqueue(qValue); - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - return true; - } - else - { - return false; - } - }; - // - - // - // Try to add an element to the queue: Add the element to the queue - // only if the lock becomes available during the specified time - // interval. - bool TryEnqueue(T qValue, int waitTime) - { - // Request the lock. - if (Monitor::TryEnter(m_inputQueue, waitTime)) - { - try - { - m_inputQueue->Enqueue(qValue); - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - return true; - } - else - { - return false; - } - }; - // - - // Lock the queue and dequeue an element. - T Dequeue() - { - T retval; - - // Request the lock, and block until it is obtained. - Monitor::Enter(m_inputQueue); - try - { - // When the lock is obtained, dequeue an element. - retval = m_inputQueue->Dequeue(); - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - - return retval; - }; - - // Delete all elements that equal the given object. - int Remove(T qValue) - { - int removedCt = 0; - - // Wait until the lock is available and lock the queue. - Monitor::Enter(m_inputQueue); - try - { - int counter = m_inputQueue->Count; - while (counter > 0) - // Check each element. - { - T elem = m_inputQueue->Dequeue(); - if (!elem->Equals(qValue)) - { - m_inputQueue->Enqueue(elem); - } - else - { - // Keep a count of items removed. - removedCt += 1; - } - counter = counter - 1; - } - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - - return removedCt; - }; - - // Print all queue elements. - String^ PrintAllElements() - { - StringBuilder^ output = gcnew StringBuilder(); - - // Lock the queue. - Monitor::Enter(m_inputQueue); - try - { - for each ( T elem in m_inputQueue ) - { - // Print the next element. - output->AppendLine(elem->ToString()); - } - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - - return output->ToString(); - }; -}; - -public ref class Example -{ -private: - static SafeQueue^ q = gcnew SafeQueue(); - static int threadsRunning = 0; - static array^>^ results = gcnew array^>(3); - - static void ThreadProc(Object^ state) - { - DateTime finish = DateTime::Now.AddSeconds(10); - Random^ rand = gcnew Random(); - array^ result = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - int threadNum = (int) state; - - while (DateTime::Now < finish) - - { - int what = rand->Next(250); - int how = rand->Next(100); - - if (how < 16) - { - q->Enqueue(what); - result[(int)ThreadResultIndex::EnqueueCt] += 1; - } - else if (how < 32) - { - if (q->TryEnqueue(what)) - { - result[(int)ThreadResultIndex::TryEnqueueSucceedCt] += 1; - } - else - { - result[(int)ThreadResultIndex::TryEnqueueFailCt] += 1; - } - } - else if (how < 48) - { - // Even a very small wait significantly increases the success - // rate of the conditional enqueue operation. - if (q->TryEnqueue(what, 10)) - { - result[(int)ThreadResultIndex::TryEnqueueWaitSucceedCt] += 1; - } - else - { - result[(int)ThreadResultIndex::TryEnqueueWaitFailCt] += 1; - } - } - else if (how < 96) - { - result[(int)ThreadResultIndex::DequeueCt] += 1; - try - { - q->Dequeue(); - } - catch (Exception^ ex) - { - result[(int)ThreadResultIndex::DequeueExCt] += 1; - } - } - else - { - result[(int)ThreadResultIndex::RemoveCt] += 1; - result[(int)ThreadResultIndex::RemovedCt] += q->Remove(what); - } - } - - results[threadNum] = result; - - if (0 == Interlocked::Decrement(threadsRunning)) - { - StringBuilder^ sb = gcnew StringBuilder( - " Thread 1 Thread 2 Thread 3 Total\n"); - - for (int row = 0; row < 9; row++) - { - int total = 0; - sb->Append(titles[row]); - - for(int col = 0; col < 3; col++) - { - sb->Append(String::Format("{0,9}", results[col][row])); - total += results[col][row]; - } - - sb->AppendLine(String::Format("{0,9}", total)); - } - - Console::WriteLine(sb->ToString()); - } - }; - - static array^ titles = { - "Enqueue ", - "TryEnqueue succeeded ", - "TryEnqueue failed ", - "TryEnqueue(T, wait) succeeded ", - "TryEnqueue(T, wait) failed ", - "Dequeue attempts ", - "Dequeue exceptions ", - "Remove operations ", - "Queue elements removed "}; - - enum class ThreadResultIndex - { - EnqueueCt, - TryEnqueueSucceedCt, - TryEnqueueFailCt, - TryEnqueueWaitSucceedCt, - TryEnqueueWaitFailCt, - DequeueCt, - DequeueExCt, - RemoveCt, - RemovedCt - }; - -public: - static void Demo() - { - Console::WriteLine("Working..."); - - for(int i = 0; i < 3; i++) - { - Thread^ t = gcnew Thread(gcnew ParameterizedThreadStart(Example::ThreadProc)); - t->Start(i); - Interlocked::Increment(threadsRunning); - } - }; -}; - -void main() -{ - Example::Demo(); -} - - -/* This example produces output similar to the following: - -Working... - Thread 1 Thread 2 Thread 3 Total -Enqueue 274718 513514 337895 1126127 -TryEnqueue succeeded 274502 513516 337480 1125498 -TryEnqueue failed 119 235 141 495 -TryEnqueue(T, wait) succeeded 274552 513116 338532 1126200 -TryEnqueue(T, wait) failed 0 1 0 1 -Dequeue attempts 824038 1541866 1015006 3380910 -Dequeue exceptions 12828 23416 14799 51043 -Remove operations 68746 128218 84306 281270 -Queue elements removed 11464 22024 14470 47958 -Queue elements removed 2921 4690 2982 10593 - */ -// - - - diff --git a/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp b/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp deleted file mode 100644 index 1cfed0722c1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Text::RegularExpressions; -int main() -{ - // - // Define a regular expression for repeated words. - Regex^ rx = gcnew Regex( "\\b(?\\w+)\\s+(\\k)\\b",static_cast(RegexOptions::Compiled | RegexOptions::IgnoreCase) ); - // - - // Define a test string. - String^ text = "The the quick brown fox fox jumps over the lazy dog dog."; - - // - // Find matches. - MatchCollection^ matches = rx->Matches( text ); - // - - // - // Report the number of matches found. - Console::WriteLine( "{0} matches found.", matches->Count ); - // - - // - // Report on each match. - for each (Match^ match in matches) - { - String^ word = match->Groups["word"]->Value; - int index = match->Index; - Console::WriteLine("{0} repeated at position {1}", word, index); - } - // -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp b/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp deleted file mode 100644 index ba044bc83d7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//Code Modification: Removed AppendLine and associated comment after the AppendFormat line. -//The CR/LF bytes introduces by AppendLine made the sb.Length appear incorrect. -// Before -//sb.AppendFormat("GHI{0}{1}", 'J', 'k'); -////APpend a blank line to the end of the StringBuilder. -// sb.AppendLine(); -// After -//sb.AppendFormat("GHI{0}{1}", 'J', 'k'); -//Code Modification: End -//Types:System.Text.StringBuilder -// -using namespace System; -using namespace System::Text; - -int main() -{ - // - // Create a StringBuilder that expects to hold 50 characters. - // Initialize the StringBuilder with "ABC". - StringBuilder^ sb = gcnew StringBuilder("ABC", 50); - // - - // - // Append three characters (D, E, and F) to the end of the - // StringBuilder. - sb->Append(gcnew array{'D', 'E', 'F'}); - // - - // - // Append a format string to the end of the StringBuilder. - sb->AppendFormat("GHI{0}{1}", (Char)'J', (Char)'k'); - // - - // - // Display the number of characters in the StringBuilder - // and its string. - Console::WriteLine("{0} chars: {1}", sb->Length, sb->ToString()); - // - - // - // Insert a string at the beginning of the StringBuilder. - sb->Insert(0, "Alphabet: "); - // - - // - // Replace all lowercase k's with uppercase K's. - sb->Replace('k', 'K'); - // - - // Display the number of characters in the StringBuilder - // and its string. - Console::WriteLine("{0} chars: {1}", sb->Length, sb->ToString()); -} - -// This code produces the following output. -// -// 11 chars: ABCDEFGHIJk -// 21 chars: Alphabet: ABCDEFGHIJK -// diff --git a/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp deleted file mode 100644 index 00fb6116cb7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -void ThreadProc() -{ - Thread::Sleep(2000); -}; - -void main() -{ - Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc)); - Console::WriteLine("Before setting apartment state: {0}", - t->GetApartmentState()); - - t->SetApartmentState(ApartmentState::STA); - Console::WriteLine("After setting apartment state: {0}", - t->GetApartmentState()); - - bool result = t->TrySetApartmentState(ApartmentState::MTA); - Console::WriteLine("Try to change state: {0}", result); - - t->Start(); - - Thread::Sleep(500); - - try - { - t->TrySetApartmentState(ApartmentState::STA); - } - catch (ThreadStateException^) - { - Console::WriteLine("ThreadStateException occurs " + - "if apartment state is set after starting thread."); - } - - t->Join(); -} - -/* This code example produces the following output: - -Before setting apartment state: Unknown -After setting apartment state: STA -Try to change state: False -ThreadStateException occurs if apartment state is set after starting thread. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp b/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp deleted file mode 100644 index b1f06ee79ff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Security::Permissions; -ref class ThreadWork -{ -public: - static void DoWork() - { - try - { - for ( int i = 0; i < 100; i++ ) - { - Console::WriteLine( "Thread - working." ); - Thread::Sleep( 100 ); - - } - } - catch ( ThreadAbortException^ e ) - { - Console::WriteLine( "Thread - caught ThreadAbortException - resetting." ); - Console::WriteLine( "Exception message: {0}", e->Message ); - Thread::ResetAbort(); - } - - Console::WriteLine( "Thread - still alive and working." ); - Thread::Sleep( 1000 ); - Console::WriteLine( "Thread - finished working." ); - } - -}; - -int main() -{ - ThreadStart^ myThreadDelegate = gcnew ThreadStart( ThreadWork::DoWork ); - Thread^ myThread = gcnew Thread( myThreadDelegate ); - myThread->Start(); - Thread::Sleep( 100 ); - Console::WriteLine( "Main - aborting my thread." ); - myThread->Abort(); - myThread->Join(); - Console::WriteLine( "Main ending." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp b/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp deleted file mode 100644 index 45cf4ed9674..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class ThreadWork -{ -public: - static void DoWork() - { - Console::WriteLine( "Working thread..." ); - } - -}; - -int main() -{ - ThreadStart^ myThreadDelegate = gcnew ThreadStart( ThreadWork::DoWork ); - Thread^ myThread = gcnew Thread( myThreadDelegate ); - myThread->Start(); - Thread::Sleep( 0 ); - Console::WriteLine( "In main. Attempting to restart myThread." ); - try - { - myThread->Start(); - } - catch ( ThreadStateException^ e ) - { - Console::WriteLine( "Caught: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp b/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp deleted file mode 100644 index d59246f431a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -public ref class ThreadWork -{ -public: - static void DoWork() - { - for ( int i = 0; i < 3; i++ ) - { - Console::WriteLine( "Working thread..." ); - Thread::Sleep( 100 ); - } - } -}; - -int main() -{ - ThreadStart^ myThreadDelegate = gcnew ThreadStart(&ThreadWork::DoWork); - Thread^ thread1 = gcnew Thread( myThreadDelegate ); - thread1->Start(); - for ( int i = 0; i < 3; i++ ) - { - Console::WriteLine( "In main." ); - Thread::Sleep( 100 ); - } -} -// The example displays output like the following: -// In main. -// Working thread... -// In main. -// Working thread... -// In main. -// Working thread... -// diff --git a/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp b/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp deleted file mode 100644 index a5590808eaa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp +++ /dev/null @@ -1,71 +0,0 @@ -//Types:System.Threading.WaitHandle -// -using namespace System; -using namespace System::Threading; - -public ref class WaitHandleExample -{ - // Define a random number generator for testing. -private: - static Random^ random = gcnew Random(); -public: - static void DoTask(Object^ state) - { - AutoResetEvent^ autoReset = (AutoResetEvent^) state; - int time = 1000 * random->Next(2, 10); - Console::WriteLine("Performing a task for {0} milliseconds.", time); - Thread::Sleep(time); - autoReset->Set(); - } -}; - -// -int main() -{ - // Define an array with two AutoResetEvent WaitHandles. - array^ handles = gcnew array { - gcnew AutoResetEvent(false), gcnew AutoResetEvent(false)}; - - // Queue up two tasks on two different threads; - // wait until all tasks are completed. - DateTime timeInstance = DateTime::Now; - Console::WriteLine("Main thread is waiting for BOTH tasks to " + - "complete."); - ThreadPool::QueueUserWorkItem( - gcnew WaitCallback(WaitHandleExample::DoTask), handles[0]); - ThreadPool::QueueUserWorkItem( - gcnew WaitCallback(WaitHandleExample::DoTask), handles[1]); - WaitHandle::WaitAll(handles); - // The time shown below should match the longest task. - Console::WriteLine("Both tasks are completed (time waited={0})", - (DateTime::Now - timeInstance).TotalMilliseconds); - - // Queue up two tasks on two different threads; - // wait until any tasks are completed. - timeInstance = DateTime::Now; - Console::WriteLine(); - Console::WriteLine("The main thread is waiting for either task to " + - "complete."); - ThreadPool::QueueUserWorkItem( - gcnew WaitCallback(WaitHandleExample::DoTask), handles[0]); - ThreadPool::QueueUserWorkItem( - gcnew WaitCallback(WaitHandleExample::DoTask), handles[1]); - int index = WaitHandle::WaitAny(handles); - // The time shown below should match the shortest task. - Console::WriteLine("Task {0} finished first (time waited={1}).", - index + 1, (DateTime::Now - timeInstance).TotalMilliseconds); -} -// - -// This code produces the following sample output. -// -// Main thread is waiting for BOTH tasks to complete. -// Performing a task for 7000 milliseconds. -// Performing a task for 4000 milliseconds. -// Both tasks are completed (time waited=7064.8052) - -// The main thread is waiting for either task to complete. -// Performing a task for 2000 milliseconds. -// Performing a task for 2000 milliseconds. -// Task 1 finished first (time waited=2000.6528). -// diff --git a/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp b/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp deleted file mode 100644 index 8695804de6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Text::RegularExpressions; -void main() -{ - - String^ text = "One car red car blue car"; - String^ pat = "(\\w+)\\s+(car)"; - - // Compile the regular expression. - Regex^ r = gcnew Regex( pat,RegexOptions::IgnoreCase ); - - // Match the regular expression pattern against a text string. - Match^ m = r->Match(text); - int matchCount = 0; - while ( m->Success ) - { - Console::WriteLine( "Match{0}", ++matchCount ); - for ( int i = 1; i <= 2; i++ ) - { - Group^ g = m->Groups[ i ]; - Console::WriteLine( "Group{0}='{1}'", i, g ); - CaptureCollection^ cc = g->Captures; - for ( int j = 0; j < cc->Count; j++ ) - { - Capture^ c = cc[ j ]; - System::Console::WriteLine( "Capture{0}='{1}', Position={2}", j, c, c->Index ); - } - } - m = m->NextMatch(); - } -} -// This example displays the following output: -// Match1 -// Group1='One' -// Capture0='One', Position=0 -// Group2='car' -// Capture0='car', Position=4 -// Match2 -// Group1='red' -// Capture0='red', Position=8 -// Group2='car' -// Capture0='car', Position=12 -// Match3 -// Group1='blue' -// Capture0='blue', Position=16 -// Group2='car' -// Capture0='car', Position=21 -// - diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp deleted file mode 100644 index 3cb652fc45a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// This example demonstrates the StringBuilder.AppendFormat method -// -using namespace System; -using namespace System::Text; -using namespace System::Globalization; -void Show( StringBuilder^ sbs ) -{ - Console::WriteLine( sbs ); - sbs->Length = 0; -} - -int main() -{ - StringBuilder^ sb = gcnew StringBuilder; - int var1 = 111; - float var2 = 2.22F; - String^ var3 = "abcd"; - array^var4 = {3,4.4,(Char)'X'}; - Console::WriteLine(); - Console::WriteLine( "StringBuilder.AppendFormat method:" ); - sb->AppendFormat( "1) {0}", var1 ); - Show( sb ); - sb->AppendFormat( "2) {0}, {1}", var1, var2 ); - Show( sb ); - sb->AppendFormat( "3) {0}, {1}, {2}", var1, var2, var3 ); - Show( sb ); - sb->AppendFormat( "4) {0}, {1}, {2}", var4 ); - Show( sb ); - CultureInfo^ ci = gcnew CultureInfo( "es-ES",true ); - array^temp1 = {var2}; - sb->AppendFormat( ci, "5) {0}", temp1 ); - Show( sb ); -} - -/* -This example produces the following results: - -StringBuilder.AppendFormat method: -1) 111 -2) 111, 2.22 -3) 111, 2.22, abcd -4) 3, 4.4, X -5) 2,22 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp deleted file mode 100644 index 8d70a9a85d3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -// This example demonstrates the StringBuilder.AppendLine() -// method. - -using namespace System; -using namespace System::Text; - -int main() -{ - StringBuilder^ sb = gcnew StringBuilder; - String^ line = L"A line of text."; - int number = 123; - - // Append two lines of text. - sb->AppendLine( L"The first line of text." ); - sb->AppendLine( line ); - - // Append a new line, an empty string, and a null cast as a string. - sb->AppendLine(); - sb->AppendLine( L"" ); - sb->AppendLine( L"" ); - - // Append the non-string value, 123, and two new lines. - sb->Append( number )->AppendLine()->AppendLine(); - - // Append two lines of text. - sb->AppendLine( line ); - sb->AppendLine( L"The last line of text." ); - - // Convert the value of the StringBuilder to a string and display the string. - Console::WriteLine( sb ); - - return 0; -} - -/* -This example produces the following results: - -The first line of text. -A line of text. - - - -123 - -A line of text. -The last line of text. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp deleted file mode 100644 index be8fea41b47..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -// This example demonstrates the CopyTo(Int32, Char[], Int32, Int32) method. -// Typically the destination array is small, preallocated, and global while -// the StringBuilder is large with programmatically defined data. -// However, for this example both the array and StringBuilder are small -// and the StringBuilder has predefined data. - -using namespace System; -using namespace System::Text; - -int main() -{ - array^dest = gcnew array(6); - StringBuilder^ src = gcnew StringBuilder( "abcdefghijklmnopqrstuvwxyz!" ); - dest[ 1 ] = ')'; - dest[ 2 ] = ' '; - - // Copy the source to the destination in 9 pieces, 3 characters per piece. - Console::WriteLine( "\nPiece) Data:" ); - for ( int ix = 0; ix < 9; ix++ ) - { - dest[ 0 ] = ix.ToString()[ 0 ]; - src->CopyTo( ix * 3, dest, 3, 3 ); - Console::Write( " " ); - Console::WriteLine( dest ); - } -} - -/* -This example produces the following results: - -Piece) Data: - 0) abc - 1) def - 2) ghi - 3) jkl - 4) mno - 5) pqr - 6) stu - 7) vwx - 8) yz! -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp deleted file mode 100644 index 8043d615414..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -// This example demonstrates StringBuilder.EnsureCapacity -// StringBuilder.Capacity -// StringBuilder.Length -// StringBuilder.Equals -// -using namespace System; -using namespace System::Text; -int main() -{ - StringBuilder^ sb1 = gcnew StringBuilder( "abc" ); - StringBuilder^ sb2 = gcnew StringBuilder( "abc",16 ); - Console::WriteLine(); - Console::WriteLine( "a1) sb1->Length = {0}, sb1->Capacity = {1}", sb1->Length, sb1->Capacity ); - Console::WriteLine( "a2) sb2->Length = {0}, sb2->Capacity = {1}", sb2->Length, sb2->Capacity ); - Console::WriteLine( "a3) sb1 = \"{0}\", sb2 = \"{1}\"", sb1, sb2 ); - Console::WriteLine( "a4) sb1 equals sb2: {0}", sb1->Equals( sb2 ) ); - Console::WriteLine(); - Console::WriteLine( "Ensure sb1 has a capacity of at least 50 characters." ); - sb1->EnsureCapacity( 50 ); - Console::WriteLine(); - Console::WriteLine( "b1) sb1->Length = {0}, sb1->Capacity = {1}", sb1->Length, sb1->Capacity ); - Console::WriteLine( "b2) sb2->Length = {0}, sb2->Capacity = {1}", sb2->Length, sb2->Capacity ); - Console::WriteLine( "b3) sb1 = \"{0}\", sb2 = \"{1}\"", sb1, sb2 ); - Console::WriteLine( "b4) sb1 equals sb2: {0}", sb1->Equals( sb2 ) ); - Console::WriteLine(); - Console::WriteLine( "Set the length of sb1 to zero." ); - Console::WriteLine( "Set the capacity of sb2 to 51 characters." ); - sb1->Length = 0; - sb2->Capacity = 51; - Console::WriteLine(); - Console::WriteLine( "c1) sb1->Length = {0}, sb1->Capacity = {1}", sb1->Length, sb1->Capacity ); - Console::WriteLine( "c2) sb2->Length = {0}, sb2->Capacity = {1}", sb2->Length, sb2->Capacity ); - Console::WriteLine( "c3) sb1 = \"{0}\", sb2 = \"{1}\"", sb1, sb2 ); - Console::WriteLine( "c4) sb1 equals sb2: {0}", sb1->Equals( sb2 ) ); -} - -/* -The example displays the following output: - -a1) sb1->Length = 3, sb1->Capacity = 16 -a2) sb2->Length = 3, sb2->Capacity = 16 -a3) sb1 = "abc", sb2 = "abc" -a4) sb1 equals sb2: True - -Ensure sb1 has a capacity of at least 50 characters. - -b1) sb1->Length = 3, sb1->Capacity = 50 -b2) sb2->Length = 3, sb2->Capacity = 16 -b3) sb1 = "abc", sb2 = "abc" -b4) sb1 equals sb2: False - -Set the length of sb1 to zero. -Set the capacity of sb2 to 51 characters. - -c1) sb1->Length = 0, sb1->Capacity = 50 -c2) sb2->Length = 3, sb2->Capacity = 51 -c3) sb1 = "", sb2 = "abc" -c4) sb1 equals sb2: False -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp deleted file mode 100644 index 03de6cb972e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp +++ /dev/null @@ -1,118 +0,0 @@ - -// This example demonstrates StringBuilder.Insert() -// -using namespace System; -using namespace System::Text; -ref class Sample -{ -private: - - // index: 012345 - static String^ initialValue = "--[]--"; - static StringBuilder^ sb; - -public: - static void Main() - { - String^ xyz = "xyz"; - array^abc = {'a','b','c'}; - Char star = '*'; - Object^ obj = 0; - bool xBool = true; - Byte xByte = 1; - short xInt16 = 2; - int xInt32 = 3; - long xInt64 = 4; - Decimal xDecimal = 5; - float xSingle = 6.6F; - double xDouble = 7.7; - - // The following types are not CLS-compliant. - UInt16 xUInt16 = 8; - UInt32 xUInt32 = 9; - UInt64 xUInt64 = 10; - SByte xSByte = -11; - - // - Console::WriteLine( "StringBuilder.Insert method" ); - sb = gcnew StringBuilder( initialValue ); - sb->Insert( 3, xyz, 2 ); - Show( 1, sb ); - sb->Insert( 3, xyz ); - Show( 2, sb ); - sb->Insert( 3, star ); - Show( 3, sb ); - sb->Insert( 3, abc ); - Show( 4, sb ); - sb->Insert( 3, abc, 1, 2 ); - Show( 5, sb ); - sb->Insert( 3, xBool ); // True - Show( 6, sb ); - sb->Insert( 3, obj ); // 0 - Show( 7, sb ); - sb->Insert( 3, xByte ); // 1 - Show( 8, sb ); - sb->Insert( 3, xInt16 ); // 2 - Show( 9, sb ); - sb->Insert( 3, xInt32 ); // 3 - Show( 10, sb ); - sb->Insert( 3, xInt64 ); // 4 - Show( 11, sb ); - sb->Insert( 3, xDecimal ); // 5 - Show( 12, sb ); - sb->Insert( 3, xSingle ); // 6.6 - Show( 13, sb ); - sb->Insert( 3, xDouble ); // 7.7 - Show( 14, sb ); - - // The following Insert methods are not CLS-compliant. - sb->Insert( 3, xUInt16 ); // 8 - Show( 15, sb ); - sb->Insert( 3, xUInt32 ); // 9 - Show( 16, sb ); - sb->Insert( 3, xUInt64 ); // 10 - Show( 17, sb ); - sb->Insert( 3, xSByte ); // -11 - Show( 18, sb ); - - // - } - - static void Show( int overloadNumber, StringBuilder^ sbs ) - { - Console::WriteLine( "{0,2:G} = {1}", overloadNumber, sbs ); - sb = gcnew StringBuilder( initialValue ); - } - -}; - -int main() -{ - Sample::Main(); -} - -/* -This example produces the following results: - -StringBuilder.Insert method - 1 = --[xyzxyz]-- - 2 = --[xyz]-- - 3 = --[*]-- - 4 = --[abc]-- - 5 = --[bc]-- - 6 = --[True]-- - 7 = --[0]-- - 8 = --[1]-- - 9 = --[2]-- -10 = --[3]-- -11 = --[4]-- -12 = --[5]-- -13 = --[6.6]-- -14 = --[7.7]-- -15 = --[8]-- -16 = --[9]-- -17 = --[10]-- -18 = --[-11]-- - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp deleted file mode 100644 index df36afedca8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// This example demonstrates StringBuilder.Remove() -// -using namespace System; -using namespace System::Text; -int main() -{ - String^ rule1 = "0----+----1----+----2----+----3----+----4---"; - String^ rule2 = "01234567890123456789012345678901234567890123"; - String^ str = "The quick brown fox jumps over the lazy dog."; - StringBuilder^ sb = gcnew StringBuilder( str ); - Console::WriteLine(); - Console::WriteLine( "StringBuilder.Remove method" ); - Console::WriteLine(); - Console::WriteLine( "Original value:" ); - Console::WriteLine( rule1 ); - Console::WriteLine( rule2 ); - Console::WriteLine( "{0}", sb ); - Console::WriteLine(); - sb->Remove( 10, 6 ); // Remove "brown " - Console::WriteLine( "New value:" ); - Console::WriteLine( rule1 ); - Console::WriteLine( rule2 ); - Console::WriteLine( "{0}", sb ); -} - -/* -This example produces the following results: - -StringBuilder.Remove method - -Original value: -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick brown fox jumps over the lazy dog. - -New value: -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick fox jumps over the lazy dog. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp deleted file mode 100644 index 56420a34a24..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -// This example demonstrates StringBuilder.Replace() -// -using namespace System; -using namespace System::Text; -void Show( StringBuilder^ sbs ) -{ - String^ rule1 = "0----+----1----+----2----+----3----+----4---"; - String^ rule2 = "01234567890123456789012345678901234567890123"; - Console::WriteLine( rule1 ); - Console::WriteLine( rule2 ); - Console::WriteLine( "{0}", sbs ); - Console::WriteLine(); -} - -int main() -{ - - // 0----+----1----+----2----+----3----+----4--- - // 01234567890123456789012345678901234567890123 - String^ str = "The quick br!wn d#g jumps #ver the lazy cat."; - StringBuilder^ sb = gcnew StringBuilder( str ); - Console::WriteLine(); - Console::WriteLine( "StringBuilder.Replace method" ); - Console::WriteLine(); - Console::WriteLine( "Original value:" ); - Show( sb ); - sb->Replace( '#', '!', 15, 29 ); // Some '#' -> '!' - Show( sb ); - sb->Replace( '!', 'o' ); // All '!' -> 'o' - Show( sb ); - sb->Replace( "cat", "dog" ); // All "cat" -> "dog" - Show( sb ); - sb->Replace( "dog", "fox", 15, 20 ); // Some "dog" -> "fox" - Console::WriteLine( "Final value:" ); - Show( sb ); -} - -/* -This example produces the following results: - -StringBuilder.Replace method - -Original value: -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick br!wn d#g jumps #ver the lazy cat. - -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick br!wn d!g jumps !ver the lazy cat. - -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick brown dog jumps over the lazy cat. - -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick brown dog jumps over the lazy dog. - -Final value: -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick brown fox jumps over the lazy dog. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp deleted file mode 100644 index 6728f14abce..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// -// This example demonstrates the DecoderExceptionFallback class. - -using namespace System; -using namespace System::Text; - -int main() -{ - // Create an encoding, which is equivalent to calling the - // ASCIIEncoding class constructor. - // The DecoderExceptionFallback parameter specifies that an exception - // is thrown if a character cannot be encoded. - // An encoder exception fallback is also specified, but in this code - // example the encoding operation cannot fail. - - Encoding^ asciiEncoding = Encoding::GetEncoding("us-ascii", - gcnew EncoderExceptionFallback(), gcnew DecoderExceptionFallback()); - String^ inputString = "XYZ"; - String^ decodedString; - String^ twoNewLines = Environment::NewLine + Environment::NewLine ; - - array^ encodedBytes = - gcnew array(asciiEncoding->GetByteCount(inputString)); - int numberOfEncodedBytes = 0; - - // --------------------------------------------------------------------- - Console::Clear(); - - // Display the name of the encoding. - Console::WriteLine("The name of the encoding is \"{0}\".{1}", - asciiEncoding->WebName, Environment::NewLine); - - // Display the input string in text. - Console::WriteLine("Input string ({0} characters): \"{1}\"", - inputString->Length, inputString); - - // Display the input string in hexadecimal. - Console::Write("Input string in hexadecimal: "); - for each (char c in inputString) - { - Console::Write("0x{0:X2} ", c); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Encode the input string. - - Console::WriteLine("Encode the input string..."); - - numberOfEncodedBytes = asciiEncoding->GetBytes(inputString, 0, - inputString->Length, encodedBytes, 0); - - // Display the encoded bytes. - Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}", - numberOfEncodedBytes, Environment::NewLine); - for each (Byte b in encodedBytes) - { - Console::Write("0x{0:X2} ", b); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - - // Replace the encoded byte sequences for the characters 'X' and 'Z' - // with the value 0xFF, which is outside the valid range of 0x00 to 0x7F - // for ASCIIEncoding. The resulting byte sequence is actually the - // beginning of this code example because it is the input to the decoder - // operation, and is equivalent to a corrupted or improperly encoded - // byte sequence. - - encodedBytes[0] = 0xFF; - encodedBytes[2] = 0xFF; - - Console::WriteLine("Display the corrupted byte sequence..."); - Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}", - numberOfEncodedBytes, Environment::NewLine); - for each (Byte b in encodedBytes) - { - Console::Write("0x{0:X2} ", b); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Attempt to decode the encoded bytes. However, an exception is thrown - // before the byte sequence can be decoded. - - Console::WriteLine("Compare the decoded bytes to the input string..."); - - try - { - decodedString = asciiEncoding->GetString(encodedBytes); - // This statement is never executed. - Console::WriteLine("This statement is never executed."); - } - catch (DecoderFallbackException^ ex) - { - Console::WriteLine(ex); - Console::WriteLine( - "{0}*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. ***", - Environment::NewLine); - } -} - - -/* -This code example produces the following results: - -The name of the encoding is "us-ascii". - -Input string (3 characters): "XYZ" -Input string in hexadecimal: 0x58 0x59 0x5A - -Encode the input string... -Encoded bytes in hexadecimal (3 bytes): - -0x58 0x59 0x5A - -Display the corrupted byte sequence... -Encoded bytes in hexadecimal (3 bytes): - -0xFF 0x59 0xFF - -Compare the decoded bytes to the input string... -System.Text.DecoderFallbackException: Unable to translate bytes [FF] at index 0 from speci -fied code page to Unicode. -at System.Text.DecoderExceptionFallbackBuffer.Throw(Byte[] bytesUnknown, Int32 index) -at System.Text.DecoderExceptionFallbackBuffer.Fallback(Byte[] bytesUnknown, Int32 index -) -at System.Text.DecoderFallbackBuffer.InternalFallback(Byte[] bytes, Byte* pBytes) -at System.Text.ASCIIEncoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS decoder) - -at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encod -ing) -at System.Text.ASCIIEncoding.GetString(Byte[] bytes, Int32 byteIndex, Int32 byteCount) -at System.Text.Encoding.GetString(Byte[] bytes) -at Sample.Main() - -*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. *** - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp deleted file mode 100644 index 332c5a91b7d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// -// This example demonstrates the DecoderReplacementFallback class. - -using namespace System; -using namespace System::Text; - -int main() -{ - // Create an encoding, which is equivalent to calling the - // ASCIIEncoding class constructor. - // The DecoderReplacementFallback parameter specifies that the - // string "(error)" is to replace characters that cannot be decoded. - // An encoder replacement fallback is also specified, but in this code - // example the encoding operation cannot fail. - - Encoding^ asciiEncoding = Encoding::GetEncoding("us-ascii", - gcnew EncoderReplacementFallback("(unknown)"), - gcnew DecoderReplacementFallback("(error)")); - String^ inputString = "XYZ"; - String^ decodedString; - String^ twoNewLines = Environment::NewLine + Environment::NewLine; - array^ encodedBytes = gcnew array( - asciiEncoding->GetByteCount(inputString)); - int numberOfEncodedBytes = 0; - - // --------------------------------------------------------------------- - Console::Clear(); - - // Display the name of the encoding. - Console::WriteLine("The name of the encoding is \"{0}\".{1}", - asciiEncoding->WebName, Environment::NewLine); - - // Display the input string in text. - Console::WriteLine("Input string ({0} characters): \"{1}\"", - inputString->Length, inputString); - - // Display the input string in hexadecimal. - Console::Write("Input string in hexadecimal: "); - for each (char c in inputString) - { - Console::Write("0x{0:X2} ", c); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Encode the input string. - - Console::WriteLine("Encode the input string..."); - numberOfEncodedBytes = asciiEncoding->GetBytes(inputString, 0, - inputString->Length, encodedBytes, 0); - - // Display the encoded bytes. - Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}", - numberOfEncodedBytes, Environment::NewLine); - for each (Byte b in encodedBytes) - { - Console::Write("0x{0:X2} ", b); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - - // Replace the encoded byte sequences for the characters 'X' and 'Z' - // with the value 0xFF, which is outside the valid range of 0x00 to 0x7F - // for ASCIIEncoding. The resulting byte sequence is actually the - // beginning of this code example because it is the input to the decoder - // operation, and is equivalent to a corrupted or improperly encoded - // byte sequence. - - encodedBytes[0] = 0xFF; - encodedBytes[2] = 0xFF; - - Console::WriteLine("Display the corrupted byte sequence..."); - Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}", - numberOfEncodedBytes, Environment::NewLine); - for each (Byte b in encodedBytes) - { - Console::Write("0x{0:X2} ", b); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Decode the encoded bytes. - - Console::WriteLine("Compare the decoded bytes to the input string..."); - decodedString = asciiEncoding->GetString(encodedBytes); - - // Display the input string and the decoded string for comparison. - Console::WriteLine("Input string: \"{0}\"", inputString); - Console::WriteLine("Decoded string:\"{0}\"", decodedString); -} -/* -This code example produces the following results: - -The name of the encoding is "us-ascii". - -Input string (3 characters): "XYZ" -Input string in hexadecimal: 0x58 0x59 0x5A - -Encode the input string... -Encoded bytes in hexadecimal (3 bytes): - -0x58 0x59 0x5A - -Display the corrupted byte sequence... -Encoded bytes in hexadecimal (3 bytes): - -0xFF 0x59 0xFF - -Compare the decoded bytes to the input string... -Input string: "XYZ" -Decoded string:"(error)Y(error)" - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp deleted file mode 100644 index 3207d7a7fb2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// -// This example demonstrates the EncoderExceptionFallback class. - -using namespace System; -using namespace System::Text; - -int main() -{ - // Create an encoding, which is equivalent to calling the - // ASCIIEncoding class constructor. - // The EncoderExceptionFallback parameter causes an exception to - // be thrown when a character cannot be encoded. - // A decoder exception fallback is also specified, but it is not - // used because this example terminates during the encoding operation. - - Encoding^ asciiEncoding = Encoding::GetEncoding("us-ascii", - gcnew EncoderExceptionFallback(), gcnew DecoderExceptionFallback()); - - // The input string consists of the Unicode characters LEFT POINTING - // DOUBLE ANGLE QUOTATION MARK (U+00AB), 'X' (U+0058), and RIGHT - // POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB). - // The encoding can only encode characters in the US-ASCII range of - // U+0000 through U+007F. Consequently, the characters bracketing the - // 'X' character cause an exception. - String^ inputString = L"\u00abX\u00bb"; - - String^ twoNewLines = Environment::NewLine + Environment::NewLine; - array^ encodedBytes = gcnew array( - asciiEncoding->GetMaxByteCount(inputString->Length)); - int numberOfEncodedBytes = 0; - - // --------------------------------------------------------------------- - Console::Clear(); - - // Display the name of the encoding. - Console::WriteLine("The name of the encoding is \"{0}\".{1}", - asciiEncoding->WebName, Environment::NewLine); - - // Display the input string in text. - Console::WriteLine("Input string ({0} characters): \"{1}\"", - inputString->Length, inputString); - - // Display the input string in hexadecimal. - Console::Write("Input string in hexadecimal: "); - for each (char c in inputString) - { - Console::Write("0x{0:X2} ", c); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Attempt to encode the input string. However, an exception is thrown - // before the input string can be encoded. - - Console::WriteLine("Encode the input string..."); - - // The code example terminates during the call to the GetBytes() method. - try - { - numberOfEncodedBytes = asciiEncoding->GetBytes(inputString, 0, - inputString->Length, encodedBytes, 0); - // This statement is never executed. - Console::WriteLine("This statement is never executed."); - } - catch (EncoderFallbackException^ ex) - { - Console::WriteLine(ex); - Console::WriteLine( - "{0}*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. ***", - Environment::NewLine); - } -} - -/* -This code example produces the following results: - -The name of the encoding is "us-ascii". - -Input string (3 characters): "X" -Input string in hexadecimal: 0xAB 0x58 0xBB - -Encode the input string... -System.Text.EncoderFallbackException: Unable to translate Unicode character \u00AB at inde -x 0 to specified code page. -at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index) -at System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars) -at System.Text.ASCIIEncoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 -byteCount, EncoderNLS encoder) -at System.Text.ASCIIEncoding.GetBytes(String chars, Int32 charIndex, Int32 charCount, B -yte[] bytes, Int32 byteIndex) -at Sample.Main() - -*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. *** - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp deleted file mode 100644 index ec4a3456bd1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// -// This example demonstrates the EncoderReplacementFallback class. - -using namespace System; -using namespace System::Text; - -int main() -{ - // Create an encoding, which is equivalent to calling the - // ASCIIEncoding class constructor. - // The EncoderReplacementFallback parameter specifies that the - // string, "(unknown)", replace characters that cannot be encoded. - // A decoder replacement fallback is also specified, but in this - // code example the decoding operation cannot fail. - - Encoding^ ascii = Encoding::GetEncoding("us-ascii", - gcnew EncoderReplacementFallback("(unknown)"), - gcnew DecoderReplacementFallback("(error)")); - - // The input string consists of the Unicode characters LEFT POINTING - // DOUBLE ANGLE QUOTATION MARK (U+00AB), 'X' (U+0058), and RIGHT - // POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB). - // The encoding can only encode characters in the US-ASCII range of - // U+0000 through U+007F. Consequently, the characters bracketing the - // 'X' character are replaced with the fallback replacement string, - // "(unknown)". - - String^ inputString = "\u00abX\u00bb"; - String^ decodedString; - String^ twoNewLines = Environment::NewLine + Environment::NewLine; - array ^ encodedBytes = - gcnew array(ascii->GetByteCount(inputString)); - int numberOfEncodedBytes = 0; - - // --------------------------------------------------------------------- - // Display the name of the encoding. - Console::WriteLine("The name of the encoding is \"{0}\".{1}", - ascii->WebName, Environment::NewLine); - - // Display the input string in text. - Console::WriteLine("Input string ({0} characters): \"{1}\"", - inputString->Length, inputString); - - // Display the input string in hexadecimal. - Console::Write("Input string in hexadecimal: "); - for each (char c in inputString) - { - Console::Write("0x{0:X2} ", c); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Encode the input string. - - Console::WriteLine("Encode the input string..."); - numberOfEncodedBytes = ascii->GetBytes(inputString, 0, inputString->Length, - encodedBytes, 0); - - // Display the encoded bytes. - Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}", - numberOfEncodedBytes, Environment::NewLine); - for(int i = 0; i < encodedBytes->Length; i++) - { - Console::Write("0x{0:X2} ", encodedBytes[i]); - if(((i + 1) % 6) == 0) - { - Console::WriteLine(); - } - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Decode the encoded bytes, yielding a reconstituted string. - - Console::WriteLine("Decode the encoded bytes..."); - decodedString = ascii->GetString(encodedBytes); - - // Display the input string and the decoded string for comparison. - Console::WriteLine("Input string: \"{0}\"", inputString); - Console::WriteLine("Decoded string:\"{0}\"", decodedString); -} - - - -/* -This code example produces the following results: - -The name of the encoding is "us-ascii". - -Input string (3 characters): "X" -Input string in hexadecimal: 0xAB 0x58 0xBB - -Encode the input string... -Encoded bytes in hexadecimal (19 bytes): - -0x28 0x75 0x6E 0x6B 0x6E 0x6F -0x77 0x6E 0x29 0x58 0x28 0x75 -0x6E 0x6B 0x6E 0x6F 0x77 0x6E -0x29 - -Decode the encoded bytes... -Input string: "X" -Decoded string:"(unknown)X(unknown)" - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp deleted file mode 100644 index 79399d8f51e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -int main() -{ - for (int i = 0; i < 5; i++) - { - Console::WriteLine("Sleep for 2 seconds."); - Thread::Sleep(2000); - } - - Console::WriteLine("Main thread exits."); -} - -/* This example produces the following output: - -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Main thread exits. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp deleted file mode 100644 index 4f50e318256..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -int main() -{ - TimeSpan interval = TimeSpan(0, 0, 2); - - for (int i = 0; i < 5; i++) - { - Console::WriteLine("Sleep for 2 seconds."); - Thread::Sleep(interval); - } - - Console::WriteLine("Main thread exits."); -} - -/* This example produces the following output: - -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Main thread exits. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp deleted file mode 100644 index 56512d92aca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // These bytes in UTF-8 correspond to 3 different Unicode - // characters: space (U+0020), # (U+0023), and the biohazard - // symbol (U+2623). Note the biohazard symbol requires 3 bytes - // in UTF-8 (hexadecimal e2, 98, a3). Decoders store state across - // multiple calls to GetChars, handling the case when one char - // is in multiple byte arrays. - array^bytes1 = {0x20,0x23,0xe2}; - array^bytes2 = {0x98,0xa3}; - array^chars = gcnew array(3); - Decoder^ d = Encoding::UTF8->GetDecoder(); - int charLen = d->GetChars( bytes1, 0, bytes1->Length, chars, 0 ); - - // The value of charLen should be 2 now. - charLen += d->GetChars( bytes2, 0, bytes2->Length, chars, charLen ); - for ( UInt16 index(0); index < chars->Length; ++index ) - { - Console::Write( "U+{0:X4} ", static_cast(chars[ index ]) ); - - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp deleted file mode 100644 index df797ae34f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -// Use this code inside a project created with the Visual C++ > CLR > CLR Console Application template. -// Replace the code in the default .cpp file with this code. - -#include "stdafx.h" -#using - -using namespace System; - -// To avoid confusion with other Timer classes, this sample always uses the fully-qualified -// name of System::Timers::Timer instead of a using statement for System::Timer. - -public ref class Example -{ -private: - static System::Timers::Timer^ aTimer; - -public: - static void Demo() - { - // Normally, the timer is declared at the class level, so that it stays in scope as long as it - // is needed. If the timer is declared in a long-running method, KeepAlive must be used to prevent - // the JIT compiler from allowing aggressive garbage collection to occur before the method ends. - // You can experiment with this by commenting out the class-level declaration and uncommenting - // the declaration below; then uncomment the GC.KeepAlive(aTimer) at the end of the method. - //System::Timers::Timer^ aTimer; - - // Create a timer and set a two second interval. - aTimer = gcnew System::Timers::Timer(); - aTimer->Interval = 2000; - - // Alternate method: create a Timer with an interval argument to the constructor. - //aTimer = gcnew System::Timers::Timer(2000); - - // Hook up the Elapsed event for the timer. - aTimer->Elapsed += gcnew System::Timers::ElapsedEventHandler(Example::OnTimedEvent); - - // Have the timer fire repeated events (true is the default) - aTimer->AutoReset = true; - - // Start the timer - aTimer->Enabled = true; - - Console::WriteLine("Press the Enter key to exit the program at any time... "); - Console::ReadLine(); - - // If the timer is declared in a long-running method, use KeepAlive to prevent garbage collection - // from occurring before the method ends. - //GC::KeepAlive(aTimer); - } - -private: - static void OnTimedEvent(Object^ source, System::Timers::ElapsedEventArgs^ e) - { - Console::WriteLine("The Elapsed event was raised at {0}", e->SignalTime); - } - -}; - -int main() -{ - Example::Demo(); -} - -// This example displays output like the following: -// Press the Enter key to exit the program at any time... -// The Elapsed event was raised at 5/20/2015 8:48:58 PM -// The Elapsed event was raised at 5/20/2015 8:49:00 PM -// The Elapsed event was raised at 5/20/2015 8:49:02 PM -// The Elapsed event was raised at 5/20/2015 8:49:04 PM -// The Elapsed event was raised at 5/20/2015 8:49:06 PM - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp deleted file mode 100644 index 6f843e8ba21..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Timers; - -public ref class Timer2 -{ -private: - static System::Timers::Timer^ aTimer; - -public: - static void Main() - { - // Create a new Timer with Interval set to 1.5 seconds. - double interval = 1500.0; - aTimer = gcnew System::Timers::Timer(interval); - - // Hook up the event handler for the Elapsed event. - aTimer->Elapsed += gcnew ElapsedEventHandler( OnTimedEvent ); - - // Only raise the event the first time Interval elapses. - aTimer->AutoReset = false; - aTimer->Enabled = true; - - // Ensure the event fires before the exit message appears. - System::Threading::Thread::Sleep((int) interval * 2); - Console::WriteLine("Press the Enter key to exit the program."); - Console::ReadLine(); - - // If the timer is declared in a long-running method, use - // KeepAlive to prevent garbage collection from occurring - // before the method ends. - //GC::KeepAlive(aTimer); - } - -private: - // Handle the Elapsed event. - static void OnTimedEvent( Object^ /*source*/, ElapsedEventArgs^ /*e*/ ) - { - Console::WriteLine( "Hello World!" ); - } - -}; - -int main() -{ - Timer2::Main(); -} -// The example displays the following output: -// Hello World! -// Press the Enter key to exit the program. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding Example/CPP/snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding Example/CPP/snippet.cpp deleted file mode 100644 index b1cbd4a7c59..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding Example/CPP/snippet.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -using namespace System::Text; -int main() -{ - - // The encoding. - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - - // A Unicode string with two characters outside the ASCII code range. - String^ unicodeString = L"This Unicode String* contains two characters with codes outside the ASCII code range, Pi (\u03a0) and Sigma (\u03a3)."; - Console::WriteLine( "Original String*:" ); - Console::WriteLine( unicodeString ); - - // Save positions of the special characters for later reference. - int indexOfPi = unicodeString->IndexOf( L'\u03a0' ); - int indexOfSigma = unicodeString->IndexOf( L'\u03a3' ); - - // Encode string. - array^encodedBytes = ascii->GetBytes( unicodeString ); - Console::WriteLine(); - Console::WriteLine( "Encoded bytes:" ); - IEnumerator^ myEnum = encodedBytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "->Item[ {0}]", b ); - } - - Console::WriteLine(); - - // Notice that the special characters have been replaced with - // the value 63, which is the ASCII character code for '?'. - Console::WriteLine(); - Console::WriteLine( "Value at position of Pi character: {0}", encodedBytes[ indexOfPi ] ); - Console::WriteLine( "Value at position of Sigma character: {0}", encodedBytes[ indexOfSigma ] ); - - // Decode bytes back to string. - // Notice missing Pi and Sigma characters. - String^ decodedString = ascii->GetString( encodedBytes ); - Console::WriteLine(); - Console::WriteLine( "Decoded bytes:" ); - Console::WriteLine( decodedString ); -} -// The example displays the following output: -// Original string: -// This Unicode string contains two characters with codes outside the ASCII code ra -// nge, Pi (Π) and Sigma (Σ). -// -// Encoded bytes: -// [84][104][105][115][32][85][110][105][99][111][100][101][32][115][116][114][105] -// [110][103][32][99][111][110][116][97][105][110][115][32][116][119][111][32][99][ -// 104][97][114][97][99][116][101][114][115][32][119][105][116][104][32][99][111][1 -// 00][101][115][32][111][117][116][115][105][100][101][32][116][104][101][32][65][ -// 83][67][73][73][32][99][111][100][101][32][114][97][110][103][101][44][32][80][1 -// 05][32][40][63][41][32][97][110][100][32][83][105][103][109][97][32][40][63][41] -// [46] -// -// Value at position of Pi character: 63 -// Value at position of Sigma character: 63 -// -// Decoded bytes: -// This Unicode string contains two characters with codes outside the ASCII code ra -// nge, Pi (?) and Sigma (?). -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount1 Example/CPP/getbytecount-char[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount1 Example/CPP/getbytecount-char[]-int32-int32.cpp deleted file mode 100644 index 6c219637683..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount1 Example/CPP/getbytecount-char[]-int32-int32.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int byteCount = ascii->GetByteCount( chars, 1, 2 ); - Console::WriteLine( " {0} bytes needed to encode characters.", byteCount.ToString() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount2 Example/CPP/getbytecount-string.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount2 Example/CPP/getbytecount-string.cpp deleted file mode 100644 index 9cca1f732fb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount2 Example/CPP/getbytecount-string.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - String^ chars = "ASCII Encoding Example"; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int byteCount = ascii->GetByteCount( chars ); - Console::WriteLine( " {0} bytes needed to encode string.", byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes1 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes1 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 8c299b71779..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes1 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - String^ chars = "ASCII Encoding Example"; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int byteCount = ascii->GetByteCount( chars->ToCharArray(), 6, 8 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = ascii->GetBytes( chars, 6, 8, bytes, 0 ); - Console::WriteLine( " {0} bytes used to encode string.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes2/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes2/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 50c3b1c6605..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes2/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int byteCount = ascii->GetByteCount( chars, 1, 2 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = ascii->GetBytes( chars, 1, 2, bytes, 0 ); - Console::WriteLine( " {0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp deleted file mode 100644 index 9a924b51b64..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - array^bytes = {65,83,67,73,73,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101}; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int charCount = ascii->GetCharCount( bytes, 6, 8 ); - Console::WriteLine( "{0} characters needed to decode bytes.", charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp deleted file mode 100644 index 7185ebd1815..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {65,83,67,73,73,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101}; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int charCount = ascii->GetCharCount( bytes, 6, 8 ); - chars = gcnew array(charCount); - int charsDecodedCount = ascii->GetChars( bytes, 6, 8, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp deleted file mode 100644 index 2f2f78f27ff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int charCount = 2; - int maxByteCount = ascii->GetMaxByteCount( charCount ); - Console::WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", maxByteCount, charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp deleted file mode 100644 index b6d834c02f9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int byteCount = 8; - int maxCharCount = ascii->GetMaxCharCount( byteCount ); - Console::WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", maxCharCount, byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetString1 Example/CPP/getstring-byte[].cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetString1 Example/CPP/getstring-byte[].cpp deleted file mode 100644 index b8f188b7df6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetString1 Example/CPP/getstring-byte[].cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::Text; - -int main() -{ - // Define a string. - String^ original = "ASCII Encoding Example"; - // Instantiate an ASCII encoding object. - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - - // Create an ASCII byte array. - array^ bytes = ascii->GetBytes(original); - - // Display encoded bytes. - Console::Write("Encoded bytes (in hex): "); - for each (Byte value in bytes) - Console::Write("{0:X2} ", value); - Console::WriteLine(); - - // Decode the bytes and display the resulting Unicode string. - String^ decoded = ascii->GetString(bytes); - Console::WriteLine("Decoded string: '{0}'", decoded); -} -// The example displays the following output: -// Encoded bytes (in hex): 41 53 43 49 49 20 45 6E 63 6F 64 69 6E 67 20 45 78 61 6D 70 6C 65 -// Decoded string: 'ASCII Encoding Example' -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.ctor Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.ctor Example/CPP/ctor.cpp deleted file mode 100644 index 962a0f07f41..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.ctor Example/CPP/ctor.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - String^ encodingName = ascii->EncodingName; - Console::WriteLine( "Encoding name: {0}", encodingName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp deleted file mode 100644 index 370f5662328..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - array^bytes = {85,0,110,0,105,0,99,0,111,0,100,0,101,0}; - Decoder^ uniDecoder = Encoding::Unicode->GetDecoder(); - int charCount = uniDecoder->GetCharCount( bytes, 0, bytes->Length ); - Console::WriteLine( "{0} characters needed to decode bytes.", charCount ); -} - -/* This code example produces the following output. - -7 characters needed to decode bytes. - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp deleted file mode 100644 index 7183cd449b3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {85,0,110,0,105,0,99,0,111,0,100,0,101,0}; - Decoder^ uniDecoder = Encoding::Unicode->GetDecoder(); - int charCount = uniDecoder->GetCharCount( bytes, 0, bytes->Length ); - chars = gcnew array(charCount); - int charsDecodedCount = uniDecoder->GetChars( bytes, 0, bytes->Length, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -/* This code example produces the following output. - -7 characters used to decode bytes. -Decoded chars: [U][n][i][c][o][d][e] - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.ctor Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.ctor Example/CPP/ctor.cpp deleted file mode 100644 index 70bd454cc25..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.ctor Example/CPP/ctor.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // A Decoder is obtained from an Encoding. - UnicodeEncoding^ uni = gcnew UnicodeEncoding; - Decoder^ dec1 = uni->GetDecoder(); - - // A more direct technique. - Decoder^ dec2 = Encoding::Unicode->GetDecoder(); - - // dec1 and dec2 seem to be the same. - Console::WriteLine( dec1 ); - Console::WriteLine( dec2 ); - - // Note that their hash codes differ. - Console::WriteLine( dec1->GetHashCode() ); - Console::WriteLine( dec2->GetHashCode() ); -} - -/* This code example produces the following output. - -System.Text.UnicodeEncoding+Decoder -System.Text.UnicodeEncoding+Decoder -54267293 -18643596 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp deleted file mode 100644 index 74bd7968408..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp +++ /dev/null @@ -1,125 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -void ShowArray( Array^ theArray ) -{ - IEnumerator^ myEnum = theArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::Write( "[{0}]", o ); - } - - Console::WriteLine( "\n" ); -} - -int main() -{ - - // The characters to encode. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - - // Encode characters using an Encoding Object*. - Encoding^ encoding = Encoding::UTF7; - Console::WriteLine( "Using Encoding\n--------------" ); - - // Encode complete array for comparison. - array^allCharactersFromEncoding = encoding->GetBytes( chars ); - Console::WriteLine( "All characters encoded:" ); - ShowArray( allCharactersFromEncoding ); - - // Encode characters, one-by-one. - // The Encoding Object* will NOT maintain state between calls. - array^firstchar = encoding->GetBytes( chars, 0, 1 ); - Console::WriteLine( "First character:" ); - ShowArray( firstchar ); - array^secondchar = encoding->GetBytes( chars, 1, 1 ); - Console::WriteLine( "Second character:" ); - ShowArray( secondchar ); - array^thirdchar = encoding->GetBytes( chars, 2, 1 ); - Console::WriteLine( "Third character:" ); - ShowArray( thirdchar ); - array^fourthchar = encoding->GetBytes( chars, 3, 1 ); - Console::WriteLine( "Fourth character:" ); - ShowArray( fourthchar ); - - // Now, encode characters using an Encoder Object*. - Encoder^ encoder = encoding->GetEncoder(); - Console::WriteLine( "Using Encoder\n-------------" ); - - // Encode complete array for comparison. - array^allCharactersFromEncoder = gcnew array(encoder->GetByteCount( chars, 0, chars->Length, true )); - encoder->GetBytes( chars, 0, chars->Length, allCharactersFromEncoder, 0, true ); - Console::WriteLine( "All characters encoded:" ); - ShowArray( allCharactersFromEncoder ); - - // Do not flush state; i.e. maintain state between calls. - bool bFlushState = false; - - // Encode characters one-by-one. - // By maintaining state, the Encoder will not store extra bytes in the output. - array^firstcharNoFlush = gcnew array(encoder->GetByteCount( chars, 0, 1, bFlushState )); - encoder->GetBytes( chars, 0, 1, firstcharNoFlush, 0, bFlushState ); - Console::WriteLine( "First character:" ); - ShowArray( firstcharNoFlush ); - array^secondcharNoFlush = gcnew array(encoder->GetByteCount( chars, 1, 1, bFlushState )); - encoder->GetBytes( chars, 1, 1, secondcharNoFlush, 0, bFlushState ); - Console::WriteLine( "Second character:" ); - ShowArray( secondcharNoFlush ); - array^thirdcharNoFlush = gcnew array(encoder->GetByteCount( chars, 2, 1, bFlushState )); - encoder->GetBytes( chars, 2, 1, thirdcharNoFlush, 0, bFlushState ); - Console::WriteLine( "Third character:" ); - ShowArray( thirdcharNoFlush ); - - // Must flush state on last call to GetBytes(). - bFlushState = true; - array^fourthcharNoFlush = gcnew array(encoder->GetByteCount( chars, 3, 1, bFlushState )); - encoder->GetBytes( chars, 3, 1, fourthcharNoFlush, 0, bFlushState ); - Console::WriteLine( "Fourth character:" ); - ShowArray( fourthcharNoFlush ); -} - -/* This code example produces the following output. - -Using Encoding --------------- -All characters encoded: -[43][65][54][65][68][111][119][79][109][65][54][107][45] - -First character: -[43][65][54][65][45] - -Second character: -[43][65][54][77][45] - -Third character: -[43][65][54][89][45] - -Fourth character: -[43][65][54][107][45] - -Using Encoder -------------- -All characters encoded: -[43][65][54][65][68][111][119][79][109][65][54][107][45] - -First character: -[43][65][54] - -Second character: -[65][68][111] - -Third character: -[119][79][109] - -Fourth character: -[65][54][107][45] - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp deleted file mode 100644 index d8af6efc812..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - Encoder^ uniEncoder = Encoding::Unicode->GetEncoder(); - int byteCount = uniEncoder->GetByteCount( chars, 0, chars->Length, true ); - Console::WriteLine( "{0} bytes needed to encode characters.", byteCount ); -} - -/* This code example produces the following output. - -8 bytes needed to encode characters. - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 1430f4918f5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - Encoder^ uniEncoder = Encoding::Unicode->GetEncoder(); - int byteCount = uniEncoder->GetByteCount( chars, 0, chars->Length, true ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = uniEncoder->GetBytes( chars, 0, chars->Length, bytes, 0, true ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -/* This code example produces the following output. - -8 bytes used to encode characters. -Encoded bytes: [160][3][163][3][166][3][169][3] - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.ctor Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.ctor Example/CPP/ctor.cpp deleted file mode 100644 index 0f8e033017f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.ctor Example/CPP/ctor.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // An Encoder is obtained from an Encoding. - UnicodeEncoding^ uni = gcnew UnicodeEncoding; - Encoder^ enc1 = uni->GetEncoder(); - - // A more direct technique. - Encoder^ enc2 = Encoding::Unicode->GetEncoder(); - - // enc1 and enc2 seem to be the same. - Console::WriteLine( enc1 ); - Console::WriteLine( enc2 ); - - // Note that their hash codes differ. - Console::WriteLine( enc1->GetHashCode() ); - Console::WriteLine( enc2->GetHashCode() ); -} - -/* This code example produces the following output. - -System.Text.EncoderNLS -System.Text.EncoderNLS -54267293 -18643596 - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.ASCII Example/CPP/ascii.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.ASCII Example/CPP/ascii.cpp deleted file mode 100644 index 3ea34429d23..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.ASCII Example/CPP/ascii.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - - // Create an ASCII encoding. - Encoding^ ascii = Encoding::ASCII; - - // A Unicode String* with two characters outside the ASCII code range. - String^ unicodeString = L"This unicode string contains two characters with codes outside the ASCII code range, Pi (\u03a0) and Sigma (\u03a3)."; - Console::WriteLine( "Original string:" ); - Console::WriteLine( unicodeString ); - - // Save the positions of the special characters for later reference. - int indexOfPi = unicodeString->IndexOf( L'\u03a0' ); - int indexOfSigma = unicodeString->IndexOf( L'\u03a3' ); - - // Encode the String*. - array^encodedBytes = ascii->GetBytes( unicodeString ); - Console::WriteLine(); - Console::WriteLine( "Encoded bytes:" ); - IEnumerator^ myEnum = encodedBytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); - - // Notice that the special characters have been replaced with - // the value 63, which is the ASCII character code for '?'. - Console::WriteLine(); - Console::WriteLine( "Value at position of Pi character: {0}", encodedBytes[ indexOfPi ] ); - Console::WriteLine( "Value at position of Sigma character: {0}", encodedBytes[ indexOfSigma ] ); - - // Decode bytes back to String*. - // Notice the missing Pi and Sigma characters. - String^ decodedString = ascii->GetString( encodedBytes ); - Console::WriteLine(); - Console::WriteLine( "Decoded bytes:" ); - Console::WriteLine( decodedString ); -} - -/* -This code produces the following output. - -Original string: -This unicode string contains two characters with codes outside the ASCII code range, Pi (Π) and Sigma (Σ). - -Encoded bytes: -[84][104][105][115][32][117][110][105][99][111][100][101][32][115][116][114][105][110][103][32][99][111][110][116][97][105][110][115][32][116][119][111][32][99][104][97][114][97][99][116][101][114][115][32][119][105][116][104][32][99][111][100][101][115][32][111][117][116][115][105][100][101][32][116][104][101][32][65][83][67][73][73][32][99][111][100][101][32][114][97][110][103][101][44][32][80][105][32][40][63][41][32][97][110][100][32][83][105][103][109][97][32][40][63][41][46] - -Value at position of Pi character: 63 -Value at position of Sigma character: 63 - -Decoded bytes: -This unicode string contains two characters with codes outside the ASCII code range, Pi (?) and Sigma (?). - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.BigEndianUnicode/CPP/bigendianunicode.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.BigEndianUnicode/CPP/bigendianunicode.cpp deleted file mode 100644 index 8e692e11ce8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.BigEndianUnicode/CPP/bigendianunicode.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Read a text file saved with Big Endian Unicode encoding. - System::Text::Encoding^ encoding = System::Text::Encoding::BigEndianUnicode; - StreamReader^ reader = gcnew StreamReader( "TextFile.txt",encoding ); - String^ line = reader->ReadLine(); - while ( line != nullptr ) - { - Console::WriteLine( line ); - line = reader->ReadLine(); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.CodePage/CPP/codepage.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.CodePage/CPP/codepage.cpp deleted file mode 100644 index 1c3ea4a7481..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.CodePage/CPP/codepage.cpp +++ /dev/null @@ -1,176 +0,0 @@ - -// The following code example determines the Windows code page that most closely corresponds to each encoding. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Print the header. - Console::Write( "CodePage identifier and name " ); - Console::WriteLine( "WindowsCodePage" ); - - // For every encoding, get the Windows code page for it. - System::Collections::IEnumerator^ myEnum = Encoding::GetEncodings()->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EncodingInfo ^ ei = safe_cast(myEnum->Current); - Encoding^ e = ei->GetEncoding(); - Console::Write( "{0,-6} {1,-25} ", ei->CodePage, ei->Name ); - Console::Write( "{0,-6} ", e->WindowsCodePage ); - - // Mark the ones that are different. - if ( ei->CodePage != e->WindowsCodePage ) - Console::Write( "*" ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -CodePage identifier and name WindowsCodePage -37 IBM037 1252 * -437 IBM437 1252 * -500 IBM500 1252 * -708 ASMO-708 1256 * -720 DOS-720 1256 * -737 ibm737 1253 * -775 ibm775 1257 * -850 ibm850 1252 * -852 ibm852 1250 * -855 IBM855 1252 * -857 ibm857 1254 * -858 IBM00858 1252 * -860 IBM860 1252 * -861 ibm861 1252 * -862 DOS-862 1255 * -863 IBM863 1252 * -864 IBM864 1256 * -865 IBM865 1252 * -866 cp866 1251 * -869 ibm869 1253 * -870 IBM870 1250 * -874 windows-874 874 -875 cp875 1253 * -932 shift_jis 932 -936 gb2312 936 -949 ks_c_5601-1987 949 -950 big5 950 -1026 IBM1026 1254 * -1047 IBM01047 1252 * -1140 IBM01140 1252 * -1141 IBM01141 1252 * -1142 IBM01142 1252 * -1143 IBM01143 1252 * -1144 IBM01144 1252 * -1145 IBM01145 1252 * -1146 IBM01146 1252 * -1147 IBM01147 1252 * -1148 IBM01148 1252 * -1149 IBM01149 1252 * -1200 utf-16 1200 -1201 unicodeFFFE 1200 * -1250 windows-1250 1250 -1251 windows-1251 1251 -1252 Windows-1252 1252 -1253 windows-1253 1253 -1254 windows-1254 1254 -1255 windows-1255 1255 -1256 windows-1256 1256 -1257 windows-1257 1257 -1258 windows-1258 1258 -1361 Johab 949 * -10000 macintosh 1252 * -10001 x-mac-japanese 932 * -10002 x-mac-chinesetrad 950 * -10003 x-mac-korean 949 * -10004 x-mac-arabic 1256 * -10005 x-mac-hebrew 1255 * -10006 x-mac-greek 1253 * -10007 x-mac-cyrillic 1251 * -10008 x-mac-chinesesimp 936 * -10010 x-mac-romanian 1250 * -10017 x-mac-ukrainian 1251 * -10021 x-mac-thai 874 * -10029 x-mac-ce 1250 * -10079 x-mac-icelandic 1252 * -10081 x-mac-turkish 1254 * -10082 x-mac-croatian 1250 * -12000 utf-32 1200 * -12001 utf-32BE 1200 * -20000 x-Chinese-CNS 950 * -20001 x-cp20001 950 * -20002 x-Chinese-Eten 950 * -20003 x-cp20003 950 * -20004 x-cp20004 950 * -20005 x-cp20005 950 * -20105 x-IA5 1252 * -20106 x-IA5-German 1252 * -20107 x-IA5-Swedish 1252 * -20108 x-IA5-Norwegian 1252 * -20127 us-ascii 1252 * -20261 x-cp20261 1252 * -20269 x-cp20269 1252 * -20273 IBM273 1252 * -20277 IBM277 1252 * -20278 IBM278 1252 * -20280 IBM280 1252 * -20284 IBM284 1252 * -20285 IBM285 1252 * -20290 IBM290 932 * -20297 IBM297 1252 * -20420 IBM420 1256 * -20423 IBM423 1253 * -20424 IBM424 1255 * -20833 x-EBCDIC-KoreanExtended 949 * -20838 IBM-Thai 874 * -20866 koi8-r 1251 * -20871 IBM871 1252 * -20880 IBM880 1251 * -20905 IBM905 1254 * -20924 IBM00924 1252 * -20932 EUC-JP 932 * -20936 x-cp20936 936 * -20949 x-cp20949 949 * -21025 cp1025 1251 * -21866 koi8-u 1251 * -28591 iso-8859-1 1252 * -28592 iso-8859-2 1250 * -28593 iso-8859-3 1254 * -28594 iso-8859-4 1257 * -28595 iso-8859-5 1251 * -28596 iso-8859-6 1256 * -28597 iso-8859-7 1253 * -28598 iso-8859-8 1255 * -28599 iso-8859-9 1254 * -28603 iso-8859-13 1257 * -28605 iso-8859-15 1252 * -29001 x-Europa 1252 * -38598 iso-8859-8-i 1255 * -50220 iso-2022-jp 932 * -50221 csISO2022JP 932 * -50222 iso-2022-jp 932 * -50225 iso-2022-kr 949 * -50227 x-cp50227 936 * -51932 euc-jp 932 * -51936 EUC-CN 936 * -51949 euc-kr 949 * -52936 hz-gb-2312 936 * -54936 GB18030 936 * -57002 x-iscii-de 57002 -57003 x-iscii-be 57003 -57004 x-iscii-ta 57004 -57005 x-iscii-te 57005 -57006 x-iscii-as 57006 -57007 x-iscii-or 57007 -57008 x-iscii-ka 57008 -57009 x-iscii-ma 57009 -57010 x-iscii-gu 57010 -57011 x-iscii-pa 57011 -65000 utf-7 1200 * -65001 utf-8 1200 * - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/CPP/convert.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/CPP/convert.cpp deleted file mode 100644 index 90b8851bb09..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/CPP/convert.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -using namespace System::Text; - -int main() -{ - String^ unicodeString = "This string contains the unicode character Pi (\u03a0)"; - - // Create two different encodings. - Encoding^ ascii = Encoding::ASCII; - Encoding^ unicode = Encoding::Unicode; - - // Convert the string into a byte array. - array^unicodeBytes = unicode->GetBytes( unicodeString ); - - // Perform the conversion from one encoding to the other. - array^asciiBytes = Encoding::Convert( unicode, ascii, unicodeBytes ); - - // Convert the new Byte into[] a char and[] then into a string. - array^asciiChars = gcnew array(ascii->GetCharCount( asciiBytes, 0, asciiBytes->Length )); - ascii->GetChars( asciiBytes, 0, asciiBytes->Length, asciiChars, 0 ); - String^ asciiString = gcnew String( asciiChars ); - - // Display the strings created before and after the conversion. - Console::WriteLine( "Original String*: {0}", unicodeString ); - Console::WriteLine( "Ascii converted String*: {0}", asciiString ); -} -// The example displays the following output: -// Original string: This string contains the unicode character Pi (Π) -// Ascii converted string: This string contains the unicode character Pi (?) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Equals/CPP/equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Equals/CPP/equals.cpp deleted file mode 100644 index cfdede118a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Equals/CPP/equals.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// The following code example gets two instances of the same encoding (one by codepage and another by name), and checks their equality. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Get a UTF-32 encoding by codepage. - Encoding^ e1 = Encoding::GetEncoding( 12000 ); - - // Get a UTF-32 encoding by name. - Encoding^ e2 = Encoding::GetEncoding( "utf-32" ); - - // Check their equality. - Console::WriteLine( "e1 equals e2? {0}", e1->Equals( e2 ) ); -} - -/* -This code produces the following output. - -e1 equals e2? True - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp deleted file mode 100644 index b6762b0e360..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -// The following code example determines the number of bytes required to encode a character array, -// encodes the characters, and displays the resulting bytes. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndBytes( array^chars, Encoding^ enc ); -void PrintHexBytes( array^bytes ); -int main() -{ - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // a high-surrogate value (U+D8FF) - // a low-surrogate value (U+DCFF) - array^myChars = gcnew array{ - L'z','a',L'\u0306',L'\u01FD',L'\u03B2',L'\xD8FF',L'\xDCFF' - }; - - // Get different encodings. - Encoding^ u7 = Encoding::UTF7; - Encoding^ u8 = Encoding::UTF8; - Encoding^ u16LE = Encoding::Unicode; - Encoding^ u16BE = Encoding::BigEndianUnicode; - Encoding^ u32 = Encoding::UTF32; - - // Encode the entire array, and print out the counts and the resulting bytes. - PrintCountsAndBytes( myChars, u7 ); - PrintCountsAndBytes( myChars, u8 ); - PrintCountsAndBytes( myChars, u16LE ); - PrintCountsAndBytes( myChars, u16BE ); - PrintCountsAndBytes( myChars, u32 ); -} - -void PrintCountsAndBytes( array^chars, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-30} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( chars ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( chars->Length ); - Console::Write( " {0,-3} :", iMBC ); - - // Encode the array of chars. - array^bytes = enc->GetBytes( chars ); - - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -System.Text.UTF7Encoding : 18 23 :7A 61 2B 41 77 59 42 2F 51 4F 79 32 50 2F 63 2F 77 2D -System.Text.UTF8Encoding : 12 24 :7A 61 CC 86 C7 BD CE B2 F1 8F B3 BF -System.Text.UnicodeEncoding : 14 16 :7A 00 61 00 06 03 FD 01 B2 03 FF D8 FF DC -System.Text.UnicodeEncoding : 14 16 :00 7A 00 61 03 06 01 FD 03 B2 D8 FF DC FF -System.Text.UTF32Encoding : 24 32 :7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00 FF FC 04 00 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArrIC/CPP/getbytes_chararric.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArrIC/CPP/getbytes_chararric.cpp deleted file mode 100644 index 2fd11ecfbd4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArrIC/CPP/getbytes_chararric.cpp +++ /dev/null @@ -1,85 +0,0 @@ - -// The following code example determines the number of bytes required to encode three characters from a character array, -// encodes the characters, and displays the resulting bytes. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndBytes( array^chars, int index, int count, Encoding^ enc ); -void PrintHexBytes( array^bytes ); -int main() -{ - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // a high-surrogate value (U+D8FF) - // a low-surrogate value (U+DCFF) - array^myChars = gcnew array{ - L'z',L'a',L'\u0306',L'\u01FD',L'\u03B2',L'\xD8FF',L'\xDCFF' - }; - - // Get different encodings. - Encoding^ u7 = Encoding::UTF7; - Encoding^ u8 = Encoding::UTF8; - Encoding^ u16LE = Encoding::Unicode; - Encoding^ u16BE = Encoding::BigEndianUnicode; - Encoding^ u32 = Encoding::UTF32; - - // Encode three characters starting at index 4, and print out the counts and the resulting bytes. - PrintCountsAndBytes( myChars, 4, 3, u7 ); - PrintCountsAndBytes( myChars, 4, 3, u8 ); - PrintCountsAndBytes( myChars, 4, 3, u16LE ); - PrintCountsAndBytes( myChars, 4, 3, u16BE ); - PrintCountsAndBytes( myChars, 4, 3, u32 ); -} - -void PrintCountsAndBytes( array^chars, int index, int count, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-30} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( chars, index, count ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( count ); - Console::Write( " {0,-3} :", iMBC ); - - // Encode the array of chars. - array^bytes = enc->GetBytes( chars, index, count ); - - // The following is an alternative way to encode the array of chars: - // byte[] bytes = new byte[iBC]; - // enc.GetBytes( chars, index, count, bytes, bytes.GetLowerBound(0) ); - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -System.Text.UTF7Encoding : 10 11 :2B 41 37 4C 59 2F 39 7A 2F 2D -System.Text.UTF8Encoding : 6 12 :CE B2 F1 8F B3 BF -System.Text.UnicodeEncoding : 6 8 :B2 03 FF D8 FF DC -System.Text.UnicodeEncoding : 6 8 :03 B2 D8 FF DC FF -System.Text.UTF32Encoding : 8 16 :B2 03 00 00 FF FC 04 00 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_String/CPP/getbytes_string.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_String/CPP/getbytes_string.cpp deleted file mode 100644 index bf43b1262a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_String/CPP/getbytes_string.cpp +++ /dev/null @@ -1,121 +0,0 @@ - -// The following code example determines the number of bytes required to encode a string or a range in the string, -// encodes the characters, and displays the resulting bytes. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndBytes( String^ s, Encoding^ enc ); -void PrintCountsAndBytes( String^ s, int index, int count, Encoding^ enc ); -void PrintHexBytes( array^bytes ); -int main() -{ - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // a high-surrogate value (U+D8FF) - // a low-surrogate value (U+DCFF) - String^ myStr = L"za\u0306\u01FD\u03B2\xD8FF\xDCFF"; - - // Get different encodings. - Encoding^ u7 = Encoding::UTF7; - Encoding^ u8 = Encoding::UTF8; - Encoding^ u16LE = Encoding::Unicode; - Encoding^ u16BE = Encoding::BigEndianUnicode; - Encoding^ u32 = Encoding::UTF32; - - // Encode the entire string, and print out the counts and the resulting bytes. - Console::WriteLine( "Encoding the entire string:" ); - PrintCountsAndBytes( myStr, u7 ); - PrintCountsAndBytes( myStr, u8 ); - PrintCountsAndBytes( myStr, u16LE ); - PrintCountsAndBytes( myStr, u16BE ); - PrintCountsAndBytes( myStr, u32 ); - Console::WriteLine(); - - // Encode three characters starting at index 4, and print out the counts and the resulting bytes. - Console::WriteLine( "Encoding the characters from index 4 through 6:" ); - PrintCountsAndBytes( myStr, 4, 3, u7 ); - PrintCountsAndBytes( myStr, 4, 3, u8 ); - PrintCountsAndBytes( myStr, 4, 3, u16LE ); - PrintCountsAndBytes( myStr, 4, 3, u16BE ); - PrintCountsAndBytes( myStr, 4, 3, u32 ); -} - -void PrintCountsAndBytes( String^ s, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-30} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( s ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( s->Length ); - Console::Write( " {0,-3} :", iMBC ); - - // Encode the entire string. - array^bytes = enc->GetBytes( s ); - - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintCountsAndBytes( String^ s, int index, int count, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-30} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( s->ToCharArray(), index, count ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( count ); - Console::Write( " {0,-3} :", iMBC ); - - // Encode a range of characters in the string. - array^bytes = gcnew array(iBC); - enc->GetBytes( s, index, count, bytes, bytes->GetLowerBound( 0 ) ); - - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -Encoding the entire string: -System.Text.UTF7Encoding : 18 23 :7A 61 2B 41 77 59 42 2F 51 4F 79 32 50 2F 63 2F 77 2D -System.Text.UTF8Encoding : 12 24 :7A 61 CC 86 C7 BD CE B2 F1 8F B3 BF -System.Text.UnicodeEncoding : 14 16 :7A 00 61 00 06 03 FD 01 B2 03 FF D8 FF DC -System.Text.UnicodeEncoding : 14 16 :00 7A 00 61 03 06 01 FD 03 B2 D8 FF DC FF -System.Text.UTF32Encoding : 24 32 :7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00 FF FC 04 00 - -Encoding the characters from index 4 through 6: -System.Text.UTF7Encoding : 10 11 :2B 41 37 4C 59 2F 39 7A 2F 2D -System.Text.UTF8Encoding : 6 12 :CE B2 F1 8F B3 BF -System.Text.UnicodeEncoding : 6 8 :B2 03 FF D8 FF DC -System.Text.UnicodeEncoding : 6 8 :03 B2 D8 FF DC FF -System.Text.UTF32Encoding : 8 16 :B2 03 00 00 FF FC 04 00 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetChars/CPP/getchars.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetChars/CPP/getchars.cpp deleted file mode 100644 index 14988aae74c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetChars/CPP/getchars.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -// The following code example encodes a string into an array of bytes, -// and then decodes the bytes into an array of characters. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndChars( array^bytes, Encoding^ enc ); -int main() -{ - - // Create two instances of UTF32Encoding: one with little-endian byte order and one with big-endian byte order. - Encoding^ u32LE = Encoding::GetEncoding( "utf-32" ); - Encoding^ u32BE = Encoding::GetEncoding( "utf-32BE" ); - - // Use a string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - String^ myStr = "za\u0306\u01FD\u03B2"; - - // Encode the string using the big-endian byte order. - array^barrBE = gcnew array(u32BE->GetByteCount( myStr )); - u32BE->GetBytes( myStr, 0, myStr->Length, barrBE, 0 ); - - // Encode the string using the little-endian byte order. - array^barrLE = gcnew array(u32LE->GetByteCount( myStr )); - u32LE->GetBytes( myStr, 0, myStr->Length, barrLE, 0 ); - - // Get the char counts, and decode the byte arrays. - Console::Write( "BE array with BE encoding : " ); - PrintCountsAndChars( barrBE, u32BE ); - Console::Write( "LE array with LE encoding : " ); - PrintCountsAndChars( barrLE, u32LE ); -} - -void PrintCountsAndChars( array^bytes, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-25} :", enc ); - - // Display the exact character count. - int iCC = enc->GetCharCount( bytes ); - Console::Write( " {0,-3}", iCC ); - - // Display the maximum character count. - int iMCC = enc->GetMaxCharCount( bytes->Length ); - Console::Write( " {0,-3} :", iMCC ); - - // Decode the bytes and display the characters. - array^chars = enc->GetChars( bytes ); - Console::WriteLine( chars ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -BE array with BE encoding : System.Text.UTF32Encoding : 5 12 :zăǽβ -LE array with LE encoding : System.Text.UTF32Encoding : 5 12 :zăǽβ - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetCharsIC/CPP/getcharsic.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetCharsIC/CPP/getcharsic.cpp deleted file mode 100644 index 5d42df4246f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetCharsIC/CPP/getcharsic.cpp +++ /dev/null @@ -1,69 +0,0 @@ - -// The following code example encodes a string into an array of bytes, -// and then decodes a range of the bytes into an array of characters. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndChars( array^bytes, int index, int count, Encoding^ enc ); -int main() -{ - - // Create two instances of UTF32Encoding: one with little-endian byte order and one with big-endian byte order. - Encoding^ u32LE = Encoding::GetEncoding( "utf-32" ); - Encoding^ u32BE = Encoding::GetEncoding( "utf-32BE" ); - - // Use a string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - String^ myStr = "za\u0306\u01FD\u03B2"; - - // Encode the string using the big-endian byte order. - array^barrBE = gcnew array(u32BE->GetByteCount( myStr )); - u32BE->GetBytes( myStr, 0, myStr->Length, barrBE, 0 ); - - // Encode the string using the little-endian byte order. - array^barrLE = gcnew array(u32LE->GetByteCount( myStr )); - u32LE->GetBytes( myStr, 0, myStr->Length, barrLE, 0 ); - - // Get the char counts, decode eight bytes starting at index 0, - // and print out the counts and the resulting bytes. - Console::Write( "BE array with BE encoding : " ); - PrintCountsAndChars( barrBE, 0, 8, u32BE ); - Console::Write( "LE array with LE encoding : " ); - PrintCountsAndChars( barrLE, 0, 8, u32LE ); -} - -void PrintCountsAndChars( array^bytes, int index, int count, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-25} :", enc ); - - // Display the exact character count. - int iCC = enc->GetCharCount( bytes, index, count ); - Console::Write( " {0,-3}", iCC ); - - // Display the maximum character count. - int iMCC = enc->GetMaxCharCount( count ); - Console::Write( " {0,-3} :", iMCC ); - - // Decode the bytes and display the characters. - array^chars = enc->GetChars( bytes, index, count ); - - // The following is an alternative way to decode the bytes: - // Char[] chars = new Char[iCC]; - // enc->GetChars( bytes, index, count, chars, 0 ); - Console::WriteLine( chars ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -BE array with BE encoding : System.Text.UTF32Encoding : 2 6 :za -LE array with LE encoding : System.Text.UTF32Encoding : 2 6 :za - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetPreamble Example/CPP/preamble.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetPreamble Example/CPP/preamble.cpp deleted file mode 100644 index 8b3e3c0da25..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetPreamble Example/CPP/preamble.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - Encoding^ unicode = Encoding::Unicode; - - // Get the preamble for the Unicode encoder. - // In this case the preamblecontains the Byte order mark (BOM). - array^preamble = unicode->GetPreamble(); - - // Make sure a preamble was returned - // and is large enough to contain a BOM. - if ( preamble->Length >= 2 ) - { - - // if (preamble->Item[0] == 0xFE && preamble->Item[1] == 0xFF) - if ( preamble[ 0 ] == 0xFE && preamble[ 1 ] == 0xFF ) - { - Console::WriteLine( "The Unicode encoder is encoding in big-endian order." ); - } - // else if (preamble->Item[0] == 0xFF && preamble->Item[1] == 0xFE) - else - - // else if (preamble->Item[0] == 0xFF && preamble->Item[1] == 0xFE) - if ( preamble[ 0 ] == 0xFF && preamble[ 1 ] == 0xFE ) - { - Console::WriteLine( "The Unicode encoder is encoding in little-endian order." ); - } - } -} - -/* -This code produces the following output. - -The Unicode encoder is encoding in little-endian order. - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp deleted file mode 100644 index 79ba4ed7a77..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp +++ /dev/null @@ -1,173 +0,0 @@ - -// The following code example checks the values of the Boolean properties of each encoding. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Print the header. - Console::Write( "CodePage identifier and name " ); - Console::Write( "BrDisp BrSave " ); - Console::Write( "MNDisp MNSave " ); - Console::WriteLine( "1-Byte ReadOnly " ); - - // For every encoding, get the property values. - System::Collections::IEnumerator^ myEnum = Encoding::GetEncodings()->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EncodingInfo ^ ei = safe_cast(myEnum->Current); - Encoding^ e = ei->GetEncoding(); - Console::Write( "{0,-6} {1,-25} ", ei->CodePage, ei->Name ); - Console::Write( "{0,-8} {1,-8} ", e->IsBrowserDisplay, e->IsBrowserSave ); - Console::Write( "{0,-8} {1,-8} ", e->IsMailNewsDisplay, e->IsMailNewsSave ); - Console::WriteLine( "{0,-8} {1,-8} ", e->IsSingleByte, e->IsReadOnly ); - } -} - -/* -This code produces the following output. - -CodePage identifier and name BrDisp BrSave MNDisp MNSave 1-Byte ReadOnly -37 IBM037 False False False False True True -437 IBM437 False False False False True True -500 IBM500 False False False False True True -708 ASMO-708 True True False False True True -720 DOS-720 True True False False True True -737 ibm737 False False False False True True -775 ibm775 False False False False True True -850 ibm850 False False False False True True -852 ibm852 True True False False True True -855 IBM855 False False False False True True -857 ibm857 False False False False True True -858 IBM00858 False False False False True True -860 IBM860 False False False False True True -861 ibm861 False False False False True True -862 DOS-862 True True False False True True -863 IBM863 False False False False True True -864 IBM864 False False False False True True -865 IBM865 False False False False True True -866 cp866 True True False False True True -869 ibm869 False False False False True True -870 IBM870 False False False False True True -874 windows-874 True True True True True True -875 cp875 False False False False True True -932 shift_jis True True True True False True -936 gb2312 True True True True False True -949 ks_c_5601-1987 True True True True False True -950 big5 True True True True False True -1026 IBM1026 False False False False True True -1047 IBM01047 False False False False True True -1140 IBM01140 False False False False True True -1141 IBM01141 False False False False True True -1142 IBM01142 False False False False True True -1143 IBM01143 False False False False True True -1144 IBM01144 False False False False True True -1145 IBM01145 False False False False True True -1146 IBM01146 False False False False True True -1147 IBM01147 False False False False True True -1148 IBM01148 False False False False True True -1149 IBM01149 False False False False True True -1200 utf-16 False True False False False True -1201 unicodeFFFE False False False False False True -1250 windows-1250 True True True True True True -1251 windows-1251 True True True True True True -1252 Windows-1252 True True True True True True -1253 windows-1253 True True True True True True -1254 windows-1254 True True True True True True -1255 windows-1255 True True True True True True -1256 windows-1256 True True True True True True -1257 windows-1257 True True True True True True -1258 windows-1258 True True True True True True -1361 Johab False False False False False True -10000 macintosh False False False False True True -10001 x-mac-japanese False False False False False True -10002 x-mac-chinesetrad False False False False False True -10003 x-mac-korean False False False False False True -10004 x-mac-arabic False False False False True True -10005 x-mac-hebrew False False False False True True -10006 x-mac-greek False False False False True True -10007 x-mac-cyrillic False False False False True True -10008 x-mac-chinesesimp False False False False False True -10010 x-mac-romanian False False False False True True -10017 x-mac-ukrainian False False False False True True -10021 x-mac-thai False False False False True True -10029 x-mac-ce False False False False True True -10079 x-mac-icelandic False False False False True True -10081 x-mac-turkish False False False False True True -10082 x-mac-croatian False False False False True True -12000 utf-32 False False False False False True -12001 utf-32BE False False False False False True -20000 x-Chinese-CNS False False False False False True -20001 x-cp20001 False False False False False True -20002 x-Chinese-Eten False False False False False True -20003 x-cp20003 False False False False False True -20004 x-cp20004 False False False False False True -20005 x-cp20005 False False False False False True -20105 x-IA5 False False False False True True -20106 x-IA5-German False False False False True True -20107 x-IA5-Swedish False False False False True True -20108 x-IA5-Norwegian False False False False True True -20127 us-ascii False False True True True True -20261 x-cp20261 False False False False False True -20269 x-cp20269 False False False False True True -20273 IBM273 False False False False True True -20277 IBM277 False False False False True True -20278 IBM278 False False False False True True -20280 IBM280 False False False False True True -20284 IBM284 False False False False True True -20285 IBM285 False False False False True True -20290 IBM290 False False False False True True -20297 IBM297 False False False False True True -20420 IBM420 False False False False True True -20423 IBM423 False False False False True True -20424 IBM424 False False False False True True -20833 x-EBCDIC-KoreanExtended False False False False True True -20838 IBM-Thai False False False False True True -20866 koi8-r True True True True True True -20871 IBM871 False False False False True True -20880 IBM880 False False False False True True -20905 IBM905 False False False False True True -20924 IBM00924 False False False False True True -20932 EUC-JP False False False False False True -20936 x-cp20936 False False False False False True -20949 x-cp20949 False False False False False True -21025 cp1025 False False False False True True -21866 koi8-u True True True True True True -28591 iso-8859-1 True True True True True True -28592 iso-8859-2 True True True True True True -28593 iso-8859-3 False False True True True True -28594 iso-8859-4 True True True True True True -28595 iso-8859-5 True True True True True True -28596 iso-8859-6 True True True True True True -28597 iso-8859-7 True True True True True True -28598 iso-8859-8 True True False False True True -28599 iso-8859-9 True True True True True True -28603 iso-8859-13 False False True True True True -28605 iso-8859-15 False True True True True True -29001 x-Europa False False False False True True -38598 iso-8859-8-i True True True True True True -50220 iso-2022-jp False False True True False True -50221 csISO2022JP False True True True False True -50222 iso-2022-jp False False False False False True -50225 iso-2022-kr False False True False False True -50227 x-cp50227 False False False False False True -51932 euc-jp True True True True False True -51936 EUC-CN False False False False False True -51949 euc-kr False False True True False True -52936 hz-gb-2312 True True True True False True -54936 GB18030 True True True True False True -57002 x-iscii-de False False False False False True -57003 x-iscii-be False False False False False True -57004 x-iscii-ta False False False False False True -57005 x-iscii-te False False False False False True -57006 x-iscii-as False False False False False True -57007 x-iscii-or False False False False False True -57008 x-iscii-ka False False False False False True -57009 x-iscii-ma False False False False False True -57010 x-iscii-gu False False False False False True -57011 x-iscii-pa False False False False False True -65001 utf-8 True True True True False True - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp deleted file mode 100644 index 53f98f67454..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -// The following code example retrieves the different names for each encoding -// and displays the encodings with one or more names that are different from EncodingInfo.Name. -// It displays EncodingName but does not compare against it. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Print the header. - Console::Write( "Name " ); - Console::Write( "CodePage " ); - Console::Write( "BodyName " ); - Console::Write( "HeaderName " ); - Console::Write( "WebName " ); - Console::WriteLine( "Encoding.EncodingName" ); - - // For every encoding, compare the name properties with EncodingInfo.Name. - // Display only the encodings that have one or more different names. - System::Collections::IEnumerator^ myEnum = Encoding::GetEncodings()->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EncodingInfo ^ ei = safe_cast(myEnum->Current); - Encoding^ e = ei->GetEncoding(); - if ( !ei->Name->Equals( e->BodyName ) || !ei->Name->Equals( e->HeaderName ) || !ei->Name->Equals( e->WebName ) ) - { - Console::Write( "{0,-18} ", ei->Name ); - Console::Write( "{0,-9} ", e->CodePage ); - Console::Write( "{0,-18} ", e->BodyName ); - Console::Write( "{0,-18} ", e->HeaderName ); - Console::Write( "{0,-18} ", e->WebName ); - Console::WriteLine( "{0} ", e->EncodingName ); - } - } -} - -/* -This code produces the following output. - -Name CodePage BodyName HeaderName WebName Encoding.EncodingName -shift_jis 932 iso-2022-jp iso-2022-jp shift_jis Japanese (Shift-JIS) -windows-1250 1250 iso-8859-2 windows-1250 windows-1250 Central European (Windows) -windows-1251 1251 koi8-r windows-1251 windows-1251 Cyrillic (Windows) -Windows-1252 1252 iso-8859-1 Windows-1252 Windows-1252 Western European (Windows) -windows-1253 1253 iso-8859-7 windows-1253 windows-1253 Greek (Windows) -windows-1254 1254 iso-8859-9 windows-1254 windows-1254 Turkish (Windows) -csISO2022JP 50221 iso-2022-jp iso-2022-jp csISO2022JP Japanese (JIS-Allow 1 byte Kana) -iso-2022-kr 50225 iso-2022-kr euc-kr iso-2022-kr Korean (ISO) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.WebName/CPP/webname.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.WebName/CPP/webname.cpp deleted file mode 100644 index 7b3357371c8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.WebName/CPP/webname.cpp +++ /dev/null @@ -1,39 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Web; -int main() -{ - - // Use UTF8 encoding. - Encoding^ encoding = Encoding::UTF8; - StreamWriter^ writer = gcnew StreamWriter( "Encoding.html",false,encoding ); - writer->WriteLine( "" ); - - // Write charset attribute to the html file. - // writer -> WriteLine(S""); - writer->WriteLine( String::Concat( "" ) ); - writer->WriteLine( "" ); - writer->WriteLine( "

{0}

", HttpUtility::HtmlEncode( encoding->EncodingName ) ); - writer->WriteLine( "" ); - writer->Flush(); - writer->Close(); -} - -/* -This code produces the following output in an HTML file. - - - - -

Unicode (UTF-8)

- - -*/ -//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp deleted file mode 100644 index 60ac3dd0f2b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp +++ /dev/null @@ -1,188 +0,0 @@ - -// The following code example retrieves the different names for each encoding -// and compares them with the equivalent Encoding names. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Print the header. - Console::Write( "Info.CodePage " ); - Console::Write( "Info.Name " ); - Console::Write( "Info.DisplayName" ); - Console::WriteLine(); - - // Display the EncodingInfo names for every encoding, and compare with the equivalent Encoding names. - System::Collections::IEnumerator^ myEnum = Encoding::GetEncodings()->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EncodingInfo ^ ei = safe_cast(myEnum->Current); - Encoding^ e = ei->GetEncoding(); - Console::Write( "{0,-15}", ei->CodePage ); - if ( ei->CodePage == e->CodePage ) - Console::Write( " " ); - else - Console::Write( "*** " ); - Console::Write( "{0,-25}", ei->Name ); - if ( ei->CodePage == e->CodePage ) - Console::Write( " " ); - else - Console::Write( "*** " ); - Console::Write( "{0,-25}", ei->DisplayName ); - if ( ei->CodePage == e->CodePage ) - Console::Write( " " ); - else - Console::Write( "*** " ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -Info.CodePage Info.Name Info.DisplayName -37 IBM037 IBM EBCDIC (US-Canada) -437 IBM437 OEM United States -500 IBM500 IBM EBCDIC (International) -708 ASMO-708 Arabic (ASMO 708) -720 DOS-720 Arabic (DOS) -737 ibm737 Greek (DOS) -775 ibm775 Baltic (DOS) -850 ibm850 Western European (DOS) -852 ibm852 Central European (DOS) -855 IBM855 OEM Cyrillic -857 ibm857 Turkish (DOS) -858 IBM00858 OEM Multilingual Latin I -860 IBM860 Portuguese (DOS) -861 ibm861 Icelandic (DOS) -862 DOS-862 Hebrew (DOS) -863 IBM863 French Canadian (DOS) -864 IBM864 Arabic (864) -865 IBM865 Nordic (DOS) -866 cp866 Cyrillic (DOS) -869 ibm869 Greek, Modern (DOS) -870 IBM870 IBM EBCDIC (Multilingual Latin-2) -874 windows-874 Thai (Windows) -875 cp875 IBM EBCDIC (Greek Modern) -932 shift_jis Japanese (Shift-JIS) -936 gb2312 Chinese Simplified (GB2312) -949 ks_c_5601-1987 Korean -950 big5 Chinese Traditional (Big5) -1026 IBM1026 IBM EBCDIC (Turkish Latin-5) -1047 IBM01047 IBM Latin-1 -1140 IBM01140 IBM EBCDIC (US-Canada-Euro) -1141 IBM01141 IBM EBCDIC (Germany-Euro) -1142 IBM01142 IBM EBCDIC (Denmark-Norway-Euro) -1143 IBM01143 IBM EBCDIC (Finland-Sweden-Euro) -1144 IBM01144 IBM EBCDIC (Italy-Euro) -1145 IBM01145 IBM EBCDIC (Spain-Euro) -1146 IBM01146 IBM EBCDIC (UK-Euro) -1147 IBM01147 IBM EBCDIC (France-Euro) -1148 IBM01148 IBM EBCDIC (International-Euro) -1149 IBM01149 IBM EBCDIC (Icelandic-Euro) -1200 utf-16 Unicode -1201 unicodeFFFE Unicode (Big-Endian) -1250 windows-1250 Central European (Windows) -1251 windows-1251 Cyrillic (Windows) -1252 Windows-1252 Western European (Windows) -1253 windows-1253 Greek (Windows) -1254 windows-1254 Turkish (Windows) -1255 windows-1255 Hebrew (Windows) -1256 windows-1256 Arabic (Windows) -1257 windows-1257 Baltic (Windows) -1258 windows-1258 Vietnamese (Windows) -1361 Johab Korean (Johab) -10000 macintosh Western European (Mac) -10001 x-mac-japanese Japanese (Mac) -10002 x-mac-chinesetrad Chinese Traditional (Mac) -10003 x-mac-korean Korean (Mac) -10004 x-mac-arabic Arabic (Mac) -10005 x-mac-hebrew Hebrew (Mac) -10006 x-mac-greek Greek (Mac) -10007 x-mac-cyrillic Cyrillic (Mac) -10008 x-mac-chinesesimp Chinese Simplified (Mac) -10010 x-mac-romanian Romanian (Mac) -10017 x-mac-ukrainian Ukrainian (Mac) -10021 x-mac-thai Thai (Mac) -10029 x-mac-ce Central European (Mac) -10079 x-mac-icelandic Icelandic (Mac) -10081 x-mac-turkish Turkish (Mac) -10082 x-mac-croatian Croatian (Mac) -12000 utf-32 Unicode (UTF-32) -12001 utf-32BE Unicode (UTF-32 Big-Endian) -20000 x-Chinese-CNS Chinese Traditional (CNS) -20001 x-cp20001 TCA Taiwan -20002 x-Chinese-Eten Chinese Traditional (Eten) -20003 x-cp20003 IBM5550 Taiwan -20004 x-cp20004 TeleText Taiwan -20005 x-cp20005 Wang Taiwan -20105 x-IA5 Western European (IA5) -20106 x-IA5-German German (IA5) -20107 x-IA5-Swedish Swedish (IA5) -20108 x-IA5-Norwegian Norwegian (IA5) -20127 us-ascii US-ASCII -20261 x-cp20261 T.61 -20269 x-cp20269 ISO-6937 -20273 IBM273 IBM EBCDIC (Germany) -20277 IBM277 IBM EBCDIC (Denmark-Norway) -20278 IBM278 IBM EBCDIC (Finland-Sweden) -20280 IBM280 IBM EBCDIC (Italy) -20284 IBM284 IBM EBCDIC (Spain) -20285 IBM285 IBM EBCDIC (UK) -20290 IBM290 IBM EBCDIC (Japanese katakana) -20297 IBM297 IBM EBCDIC (France) -20420 IBM420 IBM EBCDIC (Arabic) -20423 IBM423 IBM EBCDIC (Greek) -20424 IBM424 IBM EBCDIC (Hebrew) -20833 x-EBCDIC-KoreanExtended IBM EBCDIC (Korean Extended) -20838 IBM-Thai IBM EBCDIC (Thai) -20866 koi8-r Cyrillic (KOI8-R) -20871 IBM871 IBM EBCDIC (Icelandic) -20880 IBM880 IBM EBCDIC (Cyrillic Russian) -20905 IBM905 IBM EBCDIC (Turkish) -20924 IBM00924 IBM Latin-1 -20932 EUC-JP Japanese (JIS 0208-1990 and 0212-1990) -20936 x-cp20936 Chinese Simplified (GB2312-80) -20949 x-cp20949 Korean Wansung -21025 cp1025 IBM EBCDIC (Cyrillic Serbian-Bulgarian) -21866 koi8-u Cyrillic (KOI8-U) -28591 iso-8859-1 Western European (ISO) -28592 iso-8859-2 Central European (ISO) -28593 iso-8859-3 Latin 3 (ISO) -28594 iso-8859-4 Baltic (ISO) -28595 iso-8859-5 Cyrillic (ISO) -28596 iso-8859-6 Arabic (ISO) -28597 iso-8859-7 Greek (ISO) -28598 iso-8859-8 Hebrew (ISO-Visual) -28599 iso-8859-9 Turkish (ISO) -28603 iso-8859-13 Estonian (ISO) -28605 iso-8859-15 Latin 9 (ISO) -29001 x-Europa Europa -38598 iso-8859-8-i Hebrew (ISO-Logical) -50220 iso-2022-jp Japanese (JIS) -50221 csISO2022JP Japanese (JIS-Allow 1 byte Kana) -50222 iso-2022-jp Japanese (JIS-Allow 1 byte Kana - SO/SI) -50225 iso-2022-kr Korean (ISO) -50227 x-cp50227 Chinese Simplified (ISO-2022) -51932 euc-jp Japanese (EUC) -51936 EUC-CN Chinese Simplified (EUC) -51949 euc-kr Korean (EUC) -52936 hz-gb-2312 Chinese Simplified (HZ) -54936 GB18030 Chinese Simplified (GB18030) -57002 x-iscii-de ISCII Devanagari -57003 x-iscii-be ISCII Bengali -57004 x-iscii-ta ISCII Tamil -57005 x-iscii-te ISCII Telugu -57006 x-iscii-as ISCII Assamese -57007 x-iscii-or ISCII Oriya -57008 x-iscii-ka ISCII Kannada -57009 x-iscii-ma ISCII Malayalam -57010 x-iscii-gu ISCII Gujarati -57011 x-iscii-pa ISCII Punjabi -65000 utf-7 Unicode (UTF-7) -65001 utf-8 Unicode (UTF-8) - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp deleted file mode 100644 index b70e9f7092d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// This sample demonstrates how to use each member of the StringBuilder class. -// -using namespace System; -using namespace System::Text; - -ref class Constructors -{ -public: - static void Main() - { - ConstructorWithNothing(); - ConstructorWithCapacity(); - ConstructorWithString(); - ConstructorWithCapacityAndMax(); - ConstructorWithSubstring(); - ConstructorWithStringAndMax(); - - Console::Write( L"This sample completed successfully; " ); - Console::WriteLine( L"press Enter to exit." ); - Console::ReadLine(); - } - -private: - static void ConstructorWithNothing() - { - // Initialize a new StringBuilder object. - // - StringBuilder^ stringBuilder = gcnew StringBuilder; - // - } - - static void ConstructorWithCapacity() - { - // Initialize a new StringBuilder object with the specified capacity. - // - int capacity = 255; - StringBuilder^ stringBuilder = gcnew StringBuilder( capacity ); - // - } - - static void ConstructorWithString() - { - // Initialize a new StringBuilder object with the specified string. - // - String^ initialString = L"Initial string."; - StringBuilder^ stringBuilder = gcnew StringBuilder( initialString ); - // - } - - static void ConstructorWithCapacityAndMax() - { - // Initialize a new StringBuilder object with the specified capacity - // and maximum capacity. - // - int capacity = 255; - int maxCapacity = 1024; - StringBuilder^ stringBuilder = gcnew StringBuilder( capacity,maxCapacity ); - // - } - - static void ConstructorWithSubstring() - { - // Initialize a new StringBuilder object with the specified substring. - // - String^ initialString = L"Initial string for stringbuilder."; - int startIndex = 0; - int substringLength = 14; - int capacity = 255; - StringBuilder^ stringBuilder = gcnew StringBuilder( - initialString,startIndex,substringLength,capacity ); - // - } - - static void ConstructorWithStringAndMax() - { - // Initialize a new StringBuilder object with the specified string - // and maximum capacity. - // - String^ initialString = L"Initial string. "; - int capacity = 255; - StringBuilder^ stringBuilder = gcnew StringBuilder( - initialString,capacity ); - // - - // Ensure that appending the specified string will not exceed the - // maximum capacity of the object. - // - String^ phraseToAdd = L"Sentence to be appended."; - if ( (stringBuilder->Length + phraseToAdd->Length) <= - stringBuilder->MaxCapacity ) - { - stringBuilder->Append( phraseToAdd ); - } - // - - // Retrieve the string value of the StringBuilder object. - // - String^ builderResults = stringBuilder->ToString(); - // - - // Retrieve the last 10 characters of the StringBuilder object. - // - int sentenceLength = 10; - int startPosition = stringBuilder->Length - sentenceLength; - String^ endPhrase = stringBuilder->ToString( startPosition, - sentenceLength ); - // - - // Retrieve the last character of the StringBuilder object. - // - int lastCharacterPosition = stringBuilder->Length - 1; - char lastCharacter = static_cast( - stringBuilder->default[ lastCharacterPosition ] ); - // - } -}; - -int main() -{ - Constructors::Main(); -} - -// -// This sample produces the following output: -// -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/CPP/encdec.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/CPP/encdec.cpp deleted file mode 100644 index 86fc73cb09c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/CPP/encdec.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// The following code example uses an encoder and a decoder to encode a string into an array of bytes, -// and then decode the bytes into an array of characters. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Get an encoder and a decoder from UTF32Encoding. - UTF32Encoding ^ u32 = gcnew UTF32Encoding( false,true,true ); - Encoder^ myEnc = u32->GetEncoder(); - Decoder^ myDec = u32->GetDecoder(); - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - array^myChars = gcnew array(5){ - L'z',L'a',L'\u0306',L'\u01FD',L'\u03B2' - }; - Console::Write( "The original characters : " ); - Console::WriteLine( myChars ); - - // Encode the character array. - int iBC = myEnc->GetByteCount( myChars, 0, myChars.Length, true ); - array^myBytes = gcnew array(iBC); - myEnc->GetBytes( myChars, 0, myChars.Length, myBytes, 0, true ); - - // Print the resulting bytes. - Console::Write( "Using the encoder : " ); - for ( int i = 0; i < myBytes.Length; i++ ) - Console::Write( "{0:X2} ", myBytes[ i ] ); - Console::WriteLine(); - - // Decode the byte array back into an array of characters. - int iCC = myDec->GetCharCount( myBytes, 0, myBytes.Length, true ); - array^myDecodedChars = gcnew array(iCC); - myDec->GetChars( myBytes, 0, myBytes.Length, myDecodedChars, 0, true ); - - // Print the resulting characters. - Console::Write( "Using the decoder : " ); - Console::WriteLine( myDecodedChars ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -The original characters : za?? -Using the encoder : 7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00 -Using the decoder : za?? - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.Equals/CPP/equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.Equals/CPP/equals.cpp deleted file mode 100644 index a627b7388d4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.Equals/CPP/equals.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -// The following code example creates instances of the UTF32Encoding class using different parameter values and then checks them for equality. -// -using namespace System; -using namespace System::Text; -void CompareEncodings( UTF32Encoding ^ a, String^ name ); -int main() -{ - - // Create different instances of UTF32Encoding. - UTF32Encoding ^ u32 = gcnew UTF32Encoding; - UTF32Encoding ^ u32tt = gcnew UTF32Encoding( true,true ); - UTF32Encoding ^ u32tf = gcnew UTF32Encoding( true,false ); - UTF32Encoding ^ u32ft = gcnew UTF32Encoding( false,true ); - UTF32Encoding ^ u32ff = gcnew UTF32Encoding( false,false ); - - // Compare these instances with instances created using the ctor with three parameters. - CompareEncodings( u32, "u32 " ); - CompareEncodings( u32tt, "u32tt" ); - CompareEncodings( u32tf, "u32tf" ); - CompareEncodings( u32ft, "u32ft" ); - CompareEncodings( u32ff, "u32ff" ); -} - -void CompareEncodings( UTF32Encoding ^ a, String^ name ) -{ - - // Create different instances of UTF32Encoding using the ctor with three parameters. - UTF32Encoding ^ u32ttt = gcnew UTF32Encoding( true,true,true ); - UTF32Encoding ^ u32ttf = gcnew UTF32Encoding( true,true,false ); - UTF32Encoding ^ u32tft = gcnew UTF32Encoding( true,false,true ); - UTF32Encoding ^ u32tff = gcnew UTF32Encoding( true,false,false ); - UTF32Encoding ^ u32ftt = gcnew UTF32Encoding( false,true,true ); - UTF32Encoding ^ u32ftf = gcnew UTF32Encoding( false,true,false ); - UTF32Encoding ^ u32fft = gcnew UTF32Encoding( false,false,true ); - UTF32Encoding ^ u32fff = gcnew UTF32Encoding( false,false,false ); - - // Compare the specified instance with each of the instances that were just created. - Console::WriteLine( "{0} and u32ttt : {1}", name, a->Equals( u32ttt ) ); - Console::WriteLine( "{0} and u32ttf : {1}", name, a->Equals( u32ttf ) ); - Console::WriteLine( "{0} and u32tft : {1}", name, a->Equals( u32tft ) ); - Console::WriteLine( "{0} and u32tff : {1}", name, a->Equals( u32tff ) ); - Console::WriteLine( "{0} and u32ftt : {1}", name, a->Equals( u32ftt ) ); - Console::WriteLine( "{0} and u32ftf : {1}", name, a->Equals( u32ftf ) ); - Console::WriteLine( "{0} and u32fft : {1}", name, a->Equals( u32fft ) ); - Console::WriteLine( "{0} and u32fff : {1}", name, a->Equals( u32fff ) ); -} - -/* -This code produces the following output. - -u32 vs u32ttt : False -u32 vs u32ttf : False -u32 vs u32tft : False -u32 vs u32tff : False -u32 vs u32ftt : False -u32 vs u32ftf : False -u32 vs u32fft : False -u32 vs u32fff : True -u32tt vs u32ttt : False -u32tt vs u32ttf : True -u32tt vs u32tft : False -u32tt vs u32tff : False -u32tt vs u32ftt : False -u32tt vs u32ftf : False -u32tt vs u32fft : False -u32tt vs u32fff : False -u32tf vs u32ttt : False -u32tf vs u32ttf : False -u32tf vs u32tft : False -u32tf vs u32tff : True -u32tf vs u32ftt : False -u32tf vs u32ftf : False -u32tf vs u32fft : False -u32tf vs u32fff : False -u32ft vs u32ttt : False -u32ft vs u32ttf : False -u32ft vs u32tft : False -u32ft vs u32tff : False -u32ft vs u32ftt : False -u32ft vs u32ftf : True -u32ft vs u32fft : False -u32ft vs u32fff : False -u32ff vs u32ttt : False -u32ff vs u32ttf : False -u32ff vs u32tft : False -u32ff vs u32tff : False -u32ff vs u32ftt : False -u32ff vs u32ftf : False -u32ff vs u32fft : False -u32ff vs u32fff : True - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/CPP/errordetection.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/CPP/errordetection.cpp deleted file mode 100644 index c1436193d7b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/CPP/errordetection.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// The following code example demonstrates the behavior of UTF32Encoding with error detection enabled and without. -// -using namespace System; -using namespace System::Text; -void PrintDecodedString( array^bytes, Encoding^ enc ); -int main() -{ - - // Create an instance of UTF32Encoding using little-endian byte order. - // This will be used for encoding. - UTF32Encoding^ u32LE = gcnew UTF32Encoding( false,true ); - - // Create two instances of UTF32Encoding using big-endian byte order: one with error detection and one without. - // These will be used for decoding. - UTF32Encoding^ u32withED = gcnew UTF32Encoding( true,true,true ); - UTF32Encoding^ u32noED = gcnew UTF32Encoding( true,true,false ); - - // Create byte arrays from the same string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - String^ myStr = L"za\u0306\u01FD\u03B2\xD8FF\xDCFF"; - - // Encode the string using little-endian byte order. - array^myBytes = gcnew array(u32LE->GetByteCount( myStr )); - u32LE->GetBytes( myStr, 0, myStr->Length, myBytes, 0 ); - - // Decode the byte array with error detection. - Console::WriteLine( "Decoding with error detection:" ); - PrintDecodedString( myBytes, u32withED ); - - // Decode the byte array without error detection. - Console::WriteLine( "Decoding without error detection:" ); - PrintDecodedString( myBytes, u32noED ); -} - - -// Decode the bytes and display the string. -void PrintDecodedString( array^bytes, Encoding^ enc ) -{ - try - { - Console::WriteLine( " Decoded string: {0}", enc->GetString( bytes, 0, bytes->Length ) ); - } - catch ( System::ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - Console::WriteLine(); -} - -// -/* -This code produces the following output. - -Decoding with error detection: -System.ArgumentException: Invalid byte was found at byte index 3. - at System.Text.UTF32Encoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS baseDecoder) - at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encoding) - at System.Text.UTF32Encoding.GetString(Byte[] bytes, Int32 index, Int32 count) - at SamplesUTF32Encoding.PrintDecodedString(Byte[] bytes, Encoding enc) - -Decoding without error detection: - Decoded string: - -*/ diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp deleted file mode 100644 index 019b60c8871..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp +++ /dev/null @@ -1,87 +0,0 @@ - -// The following code example determines the number of bytes required to encode three characters from a character array, -// then encodes the characters and displays the resulting bytes. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndBytes( array^chars, int index, int count, Encoding^ enc ); -void PrintHexBytes( array^bytes ); -int main() -{ - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // a high-surrogate value (U+D8FF) - // a low-surrogate value (U+DCFF) - array^myChars = gcnew array(7){ - L'z',L'a',L'\u0306',L'\u01FD',L'\u03B2',L'\xD8FF',L'\xDCFF' - }; - - // Create instances of different encodings. - UTF7Encoding^ u7 = gcnew UTF7Encoding; - UTF8Encoding^ u8Nobom = gcnew UTF8Encoding( false,true ); - UTF8Encoding^ u8Bom = gcnew UTF8Encoding( true,true ); - UTF32Encoding ^ u32Nobom = gcnew UTF32Encoding( false,false,true ); - UTF32Encoding ^ u32Bom = gcnew UTF32Encoding( false,true,true ); - - // Encode three characters starting at index 4 and print out the counts and the resulting bytes. - PrintCountsAndBytes( myChars, 4, 3, u7 ); - PrintCountsAndBytes( myChars, 4, 3, u8Nobom ); - PrintCountsAndBytes( myChars, 4, 3, u8Bom ); - PrintCountsAndBytes( myChars, 4, 3, u32Nobom ); - PrintCountsAndBytes( myChars, 4, 3, u32Bom ); -} - -void PrintCountsAndBytes( array^chars, int index, int count, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-25} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( chars, index, count ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( count ); - Console::Write( " {0,-3} :", iMBC ); - - // Get the byte order mark, if any. - array^preamble = enc->GetPreamble(); - - // Combine the preamble and the encoded bytes. - array^bytes = gcnew array(preamble->Length + iBC); - Array::Copy( preamble, bytes, preamble->Length ); - enc->GetBytes( chars, index, count, bytes, preamble->Length ); - - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -System.Text.UTF7Encoding : 10 11 :2B 41 37 4C 59 2F 39 7A 2F 2D -System.Text.UTF8Encoding : 6 12 :CE B2 F1 8F B3 BF -System.Text.UTF8Encoding : 6 12 :EF BB BF CE B2 F1 8F B3 BF -System.Text.UTF32Encoding : 8 12 :B2 03 00 00 FF FC 04 00 -System.Text.UTF32Encoding : 8 12 :FF FE 00 00 B2 03 00 00 FF FC 04 00 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/CPP/getbytes_string.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/CPP/getbytes_string.cpp deleted file mode 100644 index d554ef4eb8b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/CPP/getbytes_string.cpp +++ /dev/null @@ -1,85 +0,0 @@ - -// The following code example determines the number of bytes required to encode a string, -// then encodes the string and displays the resulting bytes. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndBytes( String^ s, Encoding^ enc ); -void PrintHexBytes( array^bytes ); -int main() -{ - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // a high-surrogate value (U+D8FF) - // a low-surrogate value (U+DCFF) - String^ myStr = L"za\u0306\u01FD\u03B2\xD8FF\xDCFF"; - - // Create instances of different encodings. - UTF7Encoding^ u7 = gcnew UTF7Encoding; - UTF8Encoding^ u8Nobom = gcnew UTF8Encoding( false,true ); - UTF8Encoding^ u8Bom = gcnew UTF8Encoding( true,true ); - UTF32Encoding ^ u32Nobom = gcnew UTF32Encoding( false,false,true ); - UTF32Encoding ^ u32Bom = gcnew UTF32Encoding( false,true,true ); - - // Get the byte counts and the bytes. - PrintCountsAndBytes( myStr, u7 ); - PrintCountsAndBytes( myStr, u8Nobom ); - PrintCountsAndBytes( myStr, u8Bom ); - PrintCountsAndBytes( myStr, u32Nobom ); - PrintCountsAndBytes( myStr, u32Bom ); -} - -void PrintCountsAndBytes( String^ s, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-25} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( s ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( s->Length ); - Console::Write( " {0,-3} :", iMBC ); - - // Get the byte order mark, if any. - array^preamble = enc->GetPreamble(); - - // Combine the preamble and the encoded bytes. - array^bytes = gcnew array(preamble->Length + iBC); - Array::Copy( preamble, bytes, preamble->Length ); - enc->GetBytes( s, 0, s->Length, bytes, preamble->Length ); - - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -System.Text.UTF7Encoding : 18 23 :7A 61 2B 41 77 59 42 2F 51 4F 79 32 50 2F 63 2F 77 2D -System.Text.UTF8Encoding : 12 24 :7A 61 CC 86 C7 BD CE B2 F1 8F B3 BF -System.Text.UTF8Encoding : 12 24 :EF BB BF 7A 61 CC 86 C7 BD CE B2 F1 8F B3 BF -System.Text.UTF32Encoding : 24 28 :7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00 FF FC 04 00 -System.Text.UTF32Encoding : 24 28 :FF FE 00 00 7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00 FF FC 04 00 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp deleted file mode 100644 index beeadd8f48b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp +++ /dev/null @@ -1,88 +0,0 @@ - -// The following code example encodes a string into an array of bytes, and then decodes the bytes into an array of characters. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndChars( array^bytes, Encoding^ enc ); -int main() -{ - - // Create two instances of UTF32Encoding: one with little-endian byte order and one with big-endian byte order. - UTF32Encoding^ u32LE = gcnew UTF32Encoding( false,true,true ); - UTF32Encoding^ u32BE = gcnew UTF32Encoding( true,true,true ); - - // Create byte arrays from the same string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - String^ myStr = L"za\u0306\u01FD\u03B2\xD8FF\xDCFF"; - - // barrBE uses the big-endian byte order. - array^barrBE = gcnew array(u32BE->GetByteCount( myStr )); - u32BE->GetBytes( myStr, 0, myStr->Length, barrBE, 0 ); - - // barrLE uses the little-endian byte order. - array^barrLE = gcnew array(u32LE->GetByteCount( myStr )); - u32LE->GetBytes( myStr, 0, myStr->Length, barrLE, 0 ); - - // Get the char counts and decode the byte arrays. - Console::Write( "BE array with BE encoding : " ); - PrintCountsAndChars( barrBE, u32BE ); - Console::Write( "LE array with LE encoding : " ); - PrintCountsAndChars( barrLE, u32LE ); - - // Decode the byte arrays using an encoding with a different byte order. - Console::Write( "BE array with LE encoding : " ); - try - { - PrintCountsAndChars( barrBE, u32LE ); - } - catch ( System::ArgumentException^ e ) - { - Console::WriteLine( e->Message ); - } - - Console::Write( "LE array with BE encoding : " ); - try - { - PrintCountsAndChars( barrLE, u32BE ); - } - catch ( System::ArgumentException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -void PrintCountsAndChars( array^bytes, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-25} :", enc ); - - // Display the exact character count. - int iCC = enc->GetCharCount( bytes ); - Console::Write( " {0,-3}", iCC ); - - // Display the maximum character count. - int iMCC = enc->GetMaxCharCount( bytes->Length ); - Console::Write( " {0,-3} :", iMCC ); - - // Decode the bytes and display the characters. - array^chars = gcnew array(iCC); - enc->GetChars( bytes, 0, bytes->Length, chars, 0 ); - Console::WriteLine( chars ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -BE array with BE encoding : System.Text.UTF32Encoding : 7 14 :za??ß? -LE array with LE encoding : System.Text.UTF32Encoding : 7 14 :za??ß? -BE array with LE encoding : System.Text.UTF32Encoding :Invalid byte was found at byte index 3. -LE array with BE encoding : System.Text.UTF32Encoding :Invalid byte was found at byte index 3. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp deleted file mode 100644 index 9d05673135c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example retrieves and displays the byte order mark for different UTF32Encoding instances. -// -using namespace System; -using namespace System::Text; - -void PrintHexBytes( array^bytes ); - -int main() -{ - - // Create instances of UTF32Encoding, with the byte order mark and without. - UTF32Encoding ^ u32LeNone = gcnew UTF32Encoding; - UTF32Encoding ^ u32BeNone = gcnew UTF32Encoding( true,false ); - UTF32Encoding ^ u32LeBom = gcnew UTF32Encoding( false,true ); - UTF32Encoding ^ u32BeBom = gcnew UTF32Encoding( true,true ); - - // Display the preamble for each instance. - PrintHexBytes( u32LeNone->GetPreamble() ); - PrintHexBytes( u32BeNone->GetPreamble() ); - PrintHexBytes( u32LeBom->GetPreamble() ); - PrintHexBytes( u32BeBom->GetPreamble() ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This example displays the following output: - FF FE 00 00 - - FF FE 00 00 - 00 00 FE FF -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding Example/CPP/snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding Example/CPP/snippet.cpp deleted file mode 100644 index c84f8ce2a84..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding Example/CPP/snippet.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - - // Create a UTF-7 encoding. - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - - // A Unicode string with two characters outside a 7-bit code range. - String^ unicodeString = L"This Unicode string contains two characters with codes outside a 7-bit code range, Pi (\u03a0) and Sigma (\u03a3)."; - Console::WriteLine( "Original string:" ); - Console::WriteLine( unicodeString ); - - // Encode the string. - array^encodedBytes = utf7->GetBytes( unicodeString ); - Console::WriteLine(); - Console::WriteLine( "Encoded bytes:" ); - IEnumerator^ myEnum = encodedBytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); - - // Decode bytes back to string. - // Notice Pi and Sigma characters are still present. - String^ decodedString = utf7->GetString( encodedBytes ); - Console::WriteLine(); - Console::WriteLine( "Decoded bytes:" ); - Console::WriteLine( decodedString ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp deleted file mode 100644 index ddc015fa0f3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - int byteCount = utf7->GetByteCount( chars, 1, 2 ); - Console::WriteLine( "{0} bytes needed to encode characters.", byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 97b50574c01..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - int byteCount = utf7->GetByteCount( chars, 1, 2 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = utf7->GetBytes( chars, 1, 2, bytes, 0 ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp deleted file mode 100644 index b5e8fc2023a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {85,84,70,55,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101}; - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - int charCount = utf7->GetCharCount( bytes, 2, 8 ); - chars = gcnew array(charCount); - int charsDecodedCount = utf7->GetChars( bytes, 2, 8, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetDecoder Example/CPP/getdecoder-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetDecoder Example/CPP/getdecoder-.cpp deleted file mode 100644 index 7fb0ea443fe..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetDecoder Example/CPP/getdecoder-.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {99,43,65,119,67,103,111,65,45}; - Decoder^ utf7Decoder = Encoding::UTF7->GetDecoder(); - int charCount = utf7Decoder->GetCharCount( bytes, 0, bytes->Length ); - chars = gcnew array(charCount); - int charsDecodedCount = utf7Decoder->GetChars( bytes, 0, bytes->Length, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetEncoder Example/CPP/getencoder-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetEncoder Example/CPP/getencoder-.cpp deleted file mode 100644 index 60c28256953..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetEncoder Example/CPP/getencoder-.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars = {'a','b','c',L'\u0300',L'\ua0a0'}; - array^bytes; - Encoder^ utf7Encoder = Encoding::UTF7->GetEncoder(); - int byteCount = utf7Encoder->GetByteCount( chars, 2, 3, true ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = utf7Encoder->GetBytes( chars, 2, 3, bytes, 0, true ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp deleted file mode 100644 index e368c581615..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - int charCount = 2; - int maxByteCount = utf7->GetMaxByteCount( charCount ); - Console::WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", maxByteCount, charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp deleted file mode 100644 index e11609a9b4f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - int byteCount = 8; - int maxCharCount = utf7->GetMaxCharCount( byteCount ); - Console::WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", maxCharCount, byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor1 Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor1 Example/CPP/ctor.cpp deleted file mode 100644 index 3474715e028..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor1 Example/CPP/ctor.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - String^ encodingName = utf7->EncodingName; - Console::WriteLine( "Encoding name: {0}", encodingName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor2 Example/CPP/ctor-boolean.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor2 Example/CPP/ctor-boolean.cpp deleted file mode 100644 index 0af6372132d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor2 Example/CPP/ctor-boolean.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -void ShowArray( Array^ theArray ) -{ - IEnumerator^ myEnum = theArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::Write( "[{0}]", o ); - } - - Console::WriteLine(); -} - -int main() -{ - - // A few optional characters. - String^ chars = "!@#$"; - - // The default Encoding does not allow optional characters. - // Alternate Byte values are used. - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - array^bytes1 = utf7->GetBytes( chars ); - Console::WriteLine( "Default UTF7 Encoding:" ); - ShowArray( bytes1 ); - - // Convert back to characters. - Console::WriteLine( "Characters:" ); - ShowArray( utf7->GetChars( bytes1 ) ); - - // Now, allow optional characters. - // Optional characters are encoded with their normal code points. - UTF7Encoding^ utf7AllowOptionals = gcnew UTF7Encoding( true ); - array^bytes2 = utf7AllowOptionals->GetBytes( chars ); - Console::WriteLine( "UTF7 Encoding with optional characters allowed:" ); - ShowArray( bytes2 ); - - // Convert back to characters. - Console::WriteLine( "Characters:" ); - ShowArray( utf7AllowOptionals->GetChars( bytes2 ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.getstring/CPP/getstring.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.getstring/CPP/getstring.cpp deleted file mode 100644 index 0f2e71a46f4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.getstring/CPP/getstring.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// The following code example encodes a string into an array of bytes, and then decodes the bytes back into a string. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Create an instance of UTF7Encoding. - UTF7Encoding^ u7 = gcnew UTF7Encoding( true ); - - // Create byte arrays from the same string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - String^ myStr = "za\u0306\u01FD\u03B2"; - - // Encode the string. - array^myBArr = gcnew array(u7->GetByteCount( myStr )); - u7->GetBytes( myStr, 0, myStr->Length, myBArr, 0 ); - - // Decode the byte array. - Console::WriteLine( "The new string is: {0}", u7->GetString( myBArr, 0, myBArr->Length ) ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -The new string is: za?? - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding Example/CPP/snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding Example/CPP/snippet.cpp deleted file mode 100644 index 207ede33c02..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding Example/CPP/snippet.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -//using namespace System::Collections; - -int main() -{ - // Create a UTF-8 encoding. - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - - // A Unicode string with two characters outside an 8-bit code range. - String^ unicodeString = L"This Unicode string has 2 characters " + - L"outside the ASCII range:\n" + - L"Pi (\u03a0), and Sigma (\u03a3)."; - Console::WriteLine("Original string:"); - Console::WriteLine(unicodeString); - - // Encode the string. - array^ encodedBytes = utf8->GetBytes(unicodeString ); - Console::WriteLine(); - Console::WriteLine("Encoded bytes:"); - for (int ctr = 0; ctr < encodedBytes->Length; ctr++) { - Console::Write( "{0:X2} ", encodedBytes[ctr]); - if ((ctr + 1) % 25 == 0) - Console::WriteLine(); - } - - Console::WriteLine(); - - // Decode bytes back to string. - String^ decodedString = utf8->GetString(encodedBytes); - Console::WriteLine(); - Console::WriteLine("Decoded bytes:"); - Console::WriteLine(decodedString); -} -// The example displays the following output: -// Original string: -// This Unicode string has 2 characters outside the ASCII range: -// Pi (Ï€), and Sigma (Σ). -// -// Encoded bytes: -// 54 68 69 73 20 55 6E 69 63 6F 64 65 20 73 74 72 69 6E 67 20 68 61 73 20 32 -// 20 63 68 61 72 61 63 74 65 72 73 20 6F 75 74 73 69 64 65 20 74 68 65 20 41 -// 53 43 49 49 20 72 61 6E 67 65 3A 20 0D 0A 50 69 20 28 CE A0 29 2C 20 61 6E -// 64 20 53 69 67 6D 61 20 28 CE A3 29 2E -// -// Decoded bytes: -// This Unicode string has 2 characters outside the ASCII range: -// Pi (Ï€), and Sigma (Σ). -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CPP/equals-object.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CPP/equals-object.cpp deleted file mode 100644 index 5e6ae2e299e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CPP/equals-object.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -void DescribeEquivalence( Boolean isEquivalent ) -{ - Console::WriteLine( "{0} equivalent encoding.", (isEquivalent ? (String^)"An" : "Not an") ); -} - -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - UTF8Encoding^ utf8true = gcnew UTF8Encoding( true ); - UTF8Encoding^ utf8truetrue = gcnew UTF8Encoding( true,true ); - UTF8Encoding^ utf8falsetrue = gcnew UTF8Encoding( false,true ); - DescribeEquivalence( utf8->Equals( utf8 ) ); - DescribeEquivalence( utf8->Equals( utf8true ) ); - DescribeEquivalence( utf8->Equals( utf8truetrue ) ); - DescribeEquivalence( utf8->Equals( utf8falsetrue ) ); - DescribeEquivalence( utf8true->Equals( utf8 ) ); - DescribeEquivalence( utf8true->Equals( utf8true ) ); - DescribeEquivalence( utf8true->Equals( utf8truetrue ) ); - DescribeEquivalence( utf8true->Equals( utf8falsetrue ) ); - DescribeEquivalence( utf8truetrue->Equals( utf8 ) ); - DescribeEquivalence( utf8truetrue->Equals( utf8true ) ); - DescribeEquivalence( utf8truetrue->Equals( utf8truetrue ) ); - DescribeEquivalence( utf8truetrue->Equals( utf8falsetrue ) ); - DescribeEquivalence( utf8falsetrue->Equals( utf8 ) ); - DescribeEquivalence( utf8falsetrue->Equals( utf8true ) ); - DescribeEquivalence( utf8falsetrue->Equals( utf8truetrue ) ); - DescribeEquivalence( utf8falsetrue->Equals( utf8falsetrue ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 5adc3b4928a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int byteCount = utf8->GetByteCount( chars, 1, 2 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = utf8->GetBytes( chars, 1, 2, bytes, 0 ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp deleted file mode 100644 index e89bbb84c9e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - String^ chars = "UTF8 Encoding Example"; - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int byteCount = utf8->GetByteCount( chars->ToCharArray(), 0, 13 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = utf8->GetBytes( chars, 0, 13, bytes, 0 ); - Console::WriteLine( "{0} bytes used to encode string.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp deleted file mode 100644 index 7456dd1e21a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - array^bytes = {85,84,70,56,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101}; - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int charCount = utf8->GetCharCount( bytes, 2, 8 ); - Console::WriteLine( "{0} characters needed to decode bytes.", charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp deleted file mode 100644 index 6d629f2db9b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {85,84,70,56,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101}; - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int charCount = utf8->GetCharCount( bytes, 2, 13 ); - chars = gcnew array(charCount); - int charsDecodedCount = utf8->GetChars( bytes, 2, 13, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CPP/getdecoder-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CPP/getdecoder-.cpp deleted file mode 100644 index 3e5900dd0e4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CPP/getdecoder-.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {99,204,128,234,130,160}; - Decoder^ utf8Decoder = Encoding::UTF8->GetDecoder(); - int charCount = utf8Decoder->GetCharCount( bytes, 0, bytes->Length ); - chars = gcnew array(charCount); - int charsDecodedCount = utf8Decoder->GetChars( bytes, 0, bytes->Length, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CPP/getencoder-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CPP/getencoder-.cpp deleted file mode 100644 index 2969f330f96..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CPP/getencoder-.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars = {'a','b','c',L'\u0300',L'\ua0a0'}; - array^bytes; - Encoder^ utf8Encoder = Encoding::UTF8->GetEncoder(); - int byteCount = utf8Encoder->GetByteCount( chars, 2, 3, true ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = utf8Encoder->GetBytes( chars, 2, 3, bytes, 0, true ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetHashCode Example/CPP/gethashcode-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetHashCode Example/CPP/gethashcode-.cpp deleted file mode 100644 index 00934592f35..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetHashCode Example/CPP/gethashcode-.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Many ways to instantiate a UTF8 encoding. - UTF8Encoding^ UTF8a = gcnew UTF8Encoding; - Encoding^ UTF8b = Encoding::UTF8; - Encoding^ UTF8c = gcnew UTF8Encoding( true,true ); - Encoding^ UTF8d = gcnew UTF8Encoding( false,false ); - - // But not all are the same. - Console::WriteLine( UTF8a->GetHashCode() ); - Console::WriteLine( UTF8b->GetHashCode() ); - Console::WriteLine( UTF8c->GetHashCode() ); - Console::WriteLine( UTF8d->GetHashCode() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp deleted file mode 100644 index eaf84b21006..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int charCount = 2; - int maxByteCount = utf8->GetMaxByteCount( charCount ); - Console::WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", maxByteCount, charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp deleted file mode 100644 index 624c31a8ccf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int byteCount = 8; - int maxCharCount = utf8->GetMaxCharCount( byteCount ); - Console::WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", maxCharCount, byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp deleted file mode 100644 index 8bc22343a5c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; - -void ShowArray(array^ bytes) -{ - for each (Byte b in bytes) - Console::Write( "{0:X2} ", b); - - Console::WriteLine(); -} - -int main() -{ - // The default constructor does not provide a preamble. - UTF8Encoding^ UTF8NoPreamble = gcnew UTF8Encoding; - UTF8Encoding^ UTF8WithPreamble = gcnew UTF8Encoding( true ); - array^preamble; - preamble = UTF8NoPreamble->GetPreamble(); - Console::WriteLine( "UTF8NoPreamble" ); - Console::WriteLine( " preamble length: {0}", preamble->Length ); - Console::Write( " preamble: " ); - ShowArray( preamble ); - Console::WriteLine(); - - preamble = UTF8WithPreamble->GetPreamble(); - Console::WriteLine( "UTF8WithPreamble" ); - Console::WriteLine( " preamble length: {0}", preamble->Length ); - Console::Write( " preamble: " ); - ShowArray( preamble ); -} -// The example displays the following output: -// UTF8NoPreamble -// preamble length: 0 -// preamble: -// -// UTF8WithPreamble -// preamble length: 3 -// preamble: EF BB BF -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor1 Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor1 Example/CPP/ctor.cpp deleted file mode 100644 index 862c4ca0aec..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor1 Example/CPP/ctor.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - String^ encodingName = utf8->EncodingName; - Console::WriteLine( "Encoding name: {0}", encodingName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor2 Example/CPP/ctor-boolean.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor2 Example/CPP/ctor-boolean.cpp deleted file mode 100644 index 0dafbdef102..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor2 Example/CPP/ctor-boolean.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -void ShowArray( Array^ theArray ) -{ - IEnumerator^ myEnum = theArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::Write( "[{0}]", o ); - } - - Console::WriteLine(); -} - -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - UTF8Encoding^ utf8EmitBOM = gcnew UTF8Encoding( true ); - Console::WriteLine( "utf8 preamble:" ); - ShowArray( utf8->GetPreamble() ); - Console::WriteLine( "utf8EmitBOM:" ); - ShowArray( utf8EmitBOM->GetPreamble() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor3 Example/CPP/ctor-boolean-boolean.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor3 Example/CPP/ctor-boolean-boolean.cpp deleted file mode 100644 index 9f6b9081759..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor3 Example/CPP/ctor-boolean-boolean.cpp +++ /dev/null @@ -1,39 +0,0 @@ - -// -using namespace System; -using namespace System::Text; - -void ShowArray(Array^ theArray) -{ - for each (Byte b in theArray) { - Console::Write( "{0:X2} ", b); - } - Console::WriteLine(); -} - -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - UTF8Encoding^ utf8ThrowException = gcnew UTF8Encoding(false,true); - - // This array contains two high surrogates in a row (\uD801, \uD802). - array^chars = {'a','b','c',L'\xD801',L'\xD802','d'}; - - // The following method call will not throw an exception. - array^bytes = utf8->GetBytes( chars ); - ShowArray( bytes ); - Console::WriteLine(); - - try { - - // The following method call will throw an exception. - bytes = utf8ThrowException->GetBytes( chars ); - } - catch (EncoderFallbackException^ e ) { - Console::WriteLine("{0} exception\nMessage:\n{1}", - e->GetType()->Name, e->Message); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding Example/CPP/snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding Example/CPP/snippet.cpp deleted file mode 100644 index c498942c8f5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding Example/CPP/snippet.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - - // The encoding. - UnicodeEncoding^ unicode = gcnew UnicodeEncoding; - - // Create a String* that contains Unicode characters. - String^ unicodeString = L"This Unicode string contains two characters with codes outside the traditional ASCII code range, Pi (\u03a0) and Sigma (\u03a3)."; - Console::WriteLine( "Original string:" ); - Console::WriteLine( unicodeString ); - - // Encode the String*. - array^encodedBytes = unicode->GetBytes( unicodeString ); - Console::WriteLine(); - Console::WriteLine( "Encoded bytes:" ); - IEnumerator^ myEnum = encodedBytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); - - // Decode bytes back to String*. - // Notice Pi and Sigma characters are still present. - String^ decodedString = unicode->GetString( encodedBytes ); - Console::WriteLine(); - Console::WriteLine( "Decoded bytes:" ); - Console::WriteLine( decodedString ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.CharSize Example/CPP/charsize.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.CharSize Example/CPP/charsize.cpp deleted file mode 100644 index 39d50f0b408..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.CharSize Example/CPP/charsize.cpp +++ /dev/null @@ -1,10 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - Console::WriteLine( "Unicode character size: {0} bytes", UnicodeEncoding::CharSize ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/CPP/encdec.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/CPP/encdec.cpp deleted file mode 100644 index 7f46e6d47b0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/CPP/encdec.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// The following code example uses an encoder and a decoder to encode a string into an array of bytes, -// and then decode the bytes into an array of characters. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Get an encoder and a decoder from UnicodeEncoding. - UnicodeEncoding^ u16 = gcnew UnicodeEncoding( false,true,true ); - Encoder^ myEnc = u16->GetEncoder(); - Decoder^ myDec = u16->GetDecoder(); - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - array^myChars = gcnew array(5){ - L'z',L'a',L'\u0306',L'\u01FD',L'\u03B2' - }; - Console::Write( "The original characters : " ); - Console::WriteLine( myChars ); - - // Encode the character array. - int iBC = myEnc->GetByteCount( myChars, 0, myChars->Length, true ); - array^myBytes = gcnew array(iBC); - myEnc->GetBytes( myChars, 0, myChars->Length, myBytes, 0, true ); - - // Print the resulting bytes. - Console::Write( "Using the encoder : " ); - for ( int i = 0; i < myBytes->Length; i++ ) - Console::Write( "{0:X2} ", myBytes[ i ] ); - Console::WriteLine(); - - // Decode the byte array back into an array of characters. - int iCC = myDec->GetCharCount( myBytes, 0, myBytes->Length, true ); - array^myDecodedChars = gcnew array(iCC); - myDec->GetChars( myBytes, 0, myBytes->Length, myDecodedChars, 0, true ); - - // Print the resulting characters. - Console::Write( "Using the decoder : " ); - Console::WriteLine( myDecodedChars ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -The original characters : za??ß -Using the encoder : 7A 00 61 00 06 03 FD 01 B2 03 -Using the decoder : za??ß - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ErrorDetection/CPP/errordetection.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ErrorDetection/CPP/errordetection.cpp deleted file mode 100644 index de042ae169e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ErrorDetection/CPP/errordetection.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// The following code example demonstrates the behavior of UnicodeEncoding with error detection enabled and without. -// -using namespace System; -using namespace System::Text; -void PrintDecodedString( array^bytes, Encoding^ enc ); -int main() -{ - - // Create an instance of UnicodeEncoding using little-endian byte order. - // This will be used for encoding. - UnicodeEncoding^ u16LE = gcnew UnicodeEncoding( false,true ); - - // Create two instances of UnicodeEncoding using big-endian byte order: one with error detection and one without. - // These will be used for decoding. - UnicodeEncoding^ u16withED = gcnew UnicodeEncoding( true,true,true ); - UnicodeEncoding^ u16noED = gcnew UnicodeEncoding( true,true,false ); - - // Create byte arrays from the same string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // Latin Capital Letter U with Diaeresis (U+00DC) - String^ myStr = "za\u0306\u01FD\u03B2\u00DC"; - - // Encode the string using little-endian byte order. - array^myBytes = gcnew array(u16LE->GetByteCount( myStr )); - u16LE->GetBytes( myStr, 0, myStr->Length, myBytes, 0 ); - - // Decode the byte array with error detection. - Console::WriteLine( "Decoding with error detection:" ); - PrintDecodedString( myBytes, u16withED ); - - // Decode the byte array without error detection. - Console::WriteLine( "Decoding without error detection:" ); - PrintDecodedString( myBytes, u16noED ); -} - - -// Decode the bytes and display the string. -void PrintDecodedString( array^bytes, Encoding^ enc ) -{ - try - { - Console::WriteLine( " Decoded string: {0}", enc->GetString( bytes, 0, bytes->Length ) ); - } - catch ( System::ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - Console::WriteLine(); -} - -// -/* BUGBUG: Reproduce this output in retail build, then add to the snippet. -This code produces the following output. - -Decoding with error detection: -System.ArgumentException: Invalid byte was found at byte index 3. - at System.Text.UnicodeEncoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS baseDecoder) - at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encoding) - at System.Text.UnicodeEncoding.GetString(Byte[] bytes, Int32 index, Int32 count) - at SamplesUnicodeEncoding.PrintDecodedString(Byte[] bytes, Encoding enc) - -Decoding without error detection: - Decoded string: - -*/ diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp deleted file mode 100644 index bbefc038187..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int byteCount = Unicode->GetByteCount( chars, 1, 2 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = Unicode->GetBytes( chars, 1, 2, bytes, 0 ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 25dee60bee6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - String^ chars = "Unicode Encoding Example"; - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int byteCount = Unicode->GetByteCount( chars->ToCharArray(), 8, 8 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = Unicode->GetBytes( chars, 8, 8, bytes, 0 ); - Console::WriteLine( "{0} bytes used to encode string.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp deleted file mode 100644 index 0925c759295..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - array^bytes = {85,0,110,0,105,0,99,0,111,0,100,0,101,0}; - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int charCount = Unicode->GetCharCount( bytes, 2, 8 ); - Console::WriteLine( "{0} characters needed to decode bytes.", charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp deleted file mode 100644 index e68162a021c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {85,0,110,0,105,0,99,0,111,0,100,0,101,0}; - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int charCount = Unicode->GetCharCount( bytes, 2, 8 ); - chars = gcnew array(charCount); - int charsDecodedCount = Unicode->GetChars( bytes, 2, 8, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp deleted file mode 100644 index 08545fa0a5e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int charCount = 2; - int maxByteCount = Unicode->GetMaxByteCount( charCount ); - Console::WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", maxByteCount, charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp deleted file mode 100644 index c956533d9a8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int byteCount = 8; - int maxCharCount = Unicode->GetMaxCharCount( byteCount ); - Console::WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", maxCharCount, byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetPreamble Example/CPP/getpreamble-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetPreamble Example/CPP/getpreamble-.cpp deleted file mode 100644 index b2e176ae267..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetPreamble Example/CPP/getpreamble-.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^byteOrderMark; - byteOrderMark = Encoding::Unicode->GetPreamble(); - Console::WriteLine( "Default (little-endian) Unicode Preamble:" ); - IEnumerator^ myEnum = byteOrderMark->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine( "\n" ); - UnicodeEncoding^ bigEndianUnicode = gcnew UnicodeEncoding( true,true ); - byteOrderMark = bigEndianUnicode->GetPreamble(); - Console::WriteLine( "Big-endian Unicode Preamble:" ); - myEnum = byteOrderMark->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor Example/CPP/ctor.cpp deleted file mode 100644 index 13dd01a98bb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor Example/CPP/ctor.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UnicodeEncoding^ unicode = gcnew UnicodeEncoding; - String^ encodingName = unicode->EncodingName; - Console::WriteLine( "Encoding name: {0}", encodingName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/CPP/ctor-boolean-boolean.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/CPP/ctor-boolean-boolean.cpp deleted file mode 100644 index e295b687fdd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/CPP/ctor-boolean-boolean.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -void DescribeEquivalence( Boolean isEquivalent ) -{ - Console::WriteLine( " {0} equivalent encoding.", (isEquivalent ? (String^)"An" : "Not an") ); -} - -int main() -{ - - // Create a UnicodeEncoding without parameters. - UnicodeEncoding^ unicode = gcnew UnicodeEncoding; - - // Create a UnicodeEncoding to support little-endian Byte ordering - // and include the Unicode Byte order mark. - UnicodeEncoding^ unicodeLittleEndianBOM = gcnew UnicodeEncoding( false,true ); - - // Compare this UnicodeEncoding to the UnicodeEncoding without parameters. - DescribeEquivalence( unicode->Equals( unicodeLittleEndianBOM ) ); - - // Create a UnicodeEncoding to support little-endian Byte ordering - // and not include the Unicode Byte order mark. - UnicodeEncoding^ unicodeLittleEndianNoBOM = gcnew UnicodeEncoding( false,false ); - - // Compare this UnicodeEncoding to the UnicodeEncoding without parameters. - DescribeEquivalence( unicode->Equals( unicodeLittleEndianNoBOM ) ); - - // Create a UnicodeEncoding to support big-endian Byte ordering - // and include the Unicode Byte order mark. - UnicodeEncoding^ unicodeBigEndianBOM = gcnew UnicodeEncoding( true,true ); - - // Compare this UnicodeEncoding to the UnicodeEncoding without parameters. - DescribeEquivalence( unicode->Equals( unicodeBigEndianBOM ) ); - - // Create a UnicodeEncoding to support big-endian Byte ordering - // and not include the Unicode Byte order mark. - UnicodeEncoding^ unicodeBigEndianNoBOM = gcnew UnicodeEncoding( true,false ); - - // Compare this UnicodeEncoding to the UnicodeEncoding without parameters. - DescribeEquivalence( unicode->Equals( unicodeBigEndianNoBOM ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/CPP/koax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/CPP/koax.cpp deleted file mode 100644 index ea0fa55c83a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/CPP/koax.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -namespace SystemThreadingExample -{ - public ref class Example - { - private: - static ManualResetEvent^ dummyEvent = - gcnew ManualResetEvent(false); - - static Mutex^ orphanMutex1 = gcnew Mutex; - static Mutex^ orphanMutex2 = gcnew Mutex; - static Mutex^ orphanMutex3 = gcnew Mutex; - static Mutex^ orphanMutex4 = gcnew Mutex; - static Mutex^ orphanMutex5 = gcnew Mutex; - - public: - static void ProduceAbandonMutexException(void) - { - - // Start a thread that grabs all five mutexes, and then - // abandons them. - Thread^ abandonThread = - gcnew Thread(gcnew ThreadStart(AbandonMutex)); - - abandonThread->Start(); - - // Make sure the thread is finished. - abandonThread->Join(); - - // Wait on one of the abandoned mutexes. The WaitOne - // throws an AbandonedMutexException. - try - { - orphanMutex1->WaitOne(); - Console::WriteLine("WaitOne succeeded."); - } - catch (AbandonedMutexException^ ex) - { - Console::WriteLine("Exception in WaitOne: {0}", - ex->Message); - } - finally - { - - // Whether or not the exception was thrown, - // the current thread owns the mutex, and - // must release it. - orphanMutex1->ReleaseMutex(); - } - - - // Create an array of wait handles, consisting of one - // ManualResetEvent and two mutexes, using two more of - // the abandoned mutexes. - array ^ waitFor = {dummyEvent, - orphanMutex2, orphanMutex3}; - - // WaitAny returns when any of the wait handles in the - // array is signaled. Either of the two abandoned mutexes - // satisfy the wait, but lower of the two index values is - // returned by MutexIndex. Note that the Try block and - // the Catch block obtain the index in different ways. - try - { - int index = WaitHandle::WaitAny(waitFor); - Console::WriteLine("WaitAny succeeded."); - (safe_cast(waitFor[index]))->ReleaseMutex(); - } - catch (AbandonedMutexException^ ex) - { - Console::WriteLine("Exception in WaitAny at index {0}" - "\r\n\tMessage: {1}", ex->MutexIndex, - ex->Message); - (safe_cast(waitFor[ex->MutexIndex]))-> - ReleaseMutex(); - } - - orphanMutex3->ReleaseMutex(); - - // Use two more of the abandoned mutexes for the WaitAll - // call. WaitAll doesn't return until all wait handles - // are signaled, so the ManualResetEvent must be signaled - // by calling Set(). - dummyEvent->Set(); - waitFor[1] = orphanMutex4; - waitFor[2] = orphanMutex5; - - // Because WaitAll requires all the wait handles to be - // signaled, both mutexes must be released even if the - // exception is thrown. Thus, the ReleaseMutex calls are - // placed in the Finally block. Again, MutexIndex returns - // the lower of the two index values for the abandoned - // mutexes. - // - try - { - WaitHandle::WaitAll(waitFor); - Console::WriteLine("WaitAll succeeded."); - } - catch (AbandonedMutexException^ ex) - { - Console::WriteLine("Exception in WaitAny at index {0}" - "\r\n\tMessage: {1}", ex->MutexIndex, - ex->Message); - } - finally - { - orphanMutex4->ReleaseMutex(); - orphanMutex5->ReleaseMutex(); - } - - } - - - private: - [MTAThread] - static void AbandonMutex() - { - orphanMutex1->WaitOne(); - orphanMutex2->WaitOne(); - orphanMutex3->WaitOne(); - orphanMutex4->WaitOne(); - orphanMutex5->WaitOne(); - Console::WriteLine( - "Thread exits without releasing the mutexes."); - } - }; -} - -//Entry point of example application -[MTAThread] -int main(void) -{ - SystemThreadingExample::Example::ProduceAbandonMutexException(); -} - -// This code example produces the following output: -// Thread exits without releasing the mutexes. -// Exception in WaitOne: The wait completed due to an abandoned mutex. -// Exception in WaitAny at index 1 -// Message: The wait completed due to an abandoned mutex. -// Exception in WaitAll at index -1 -// Message: The wait completed due to an abandoned mutex. - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/class1.cpp deleted file mode 100644 index 286d1b48439..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/class1.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class MyMainClass -{ -public: - static void MyReadThreadProc() - { - while ( true ) - { - - //The value will not be read until the writer has written - // at least once since the last read. - myResetEvent->WaitOne(); - Console::WriteLine( " {0} reading value: {1}", Thread::CurrentThread->Name, number ); - } - } - - - //Initially not signaled. - static AutoResetEvent^ myResetEvent = gcnew AutoResetEvent( false ); - static int number; - literal int numIterations = 100; -}; - -int main() -{ - - //Create and start the reader thread. - Thread^ myReaderThread = gcnew Thread( gcnew ThreadStart( MyMainClass::MyReadThreadProc ) ); - myReaderThread->Name = "ReaderThread"; - myReaderThread->Start(); - for ( int i = 1; i <= MyMainClass::numIterations; i++ ) - { - Console::WriteLine( "Writer thread writing value: {0}", i ); - MyMainClass::number = i; - - //Signal that a value has been written. - MyMainClass::myResetEvent->Set(); - - //Give the Reader thread an opportunity to act. - Thread::Sleep( 1 ); - - } - - //Terminate the reader thread. - myReaderThread->Abort(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/simplerisbetter.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/simplerisbetter.cpp deleted file mode 100644 index 96444ba3776..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/simplerisbetter.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -ref class Example -{ -private: - static AutoResetEvent^ event_1 = gcnew AutoResetEvent(true); - static AutoResetEvent^ event_2 = gcnew AutoResetEvent(false); - - static void ThreadProc() - { - String^ name = Thread::CurrentThread->Name; - - Console::WriteLine("{0} waits on AutoResetEvent #1.", name); - event_1->WaitOne(); - Console::WriteLine("{0} is released from AutoResetEvent #1.", name); - - Console::WriteLine("{0} waits on AutoResetEvent #2.", name); - event_2->WaitOne(); - Console::WriteLine("{0} is released from AutoResetEvent #2.", name); - - Console::WriteLine("{0} ends.", name); - } - -public: - static void Demo() - { - Console::WriteLine("Press Enter to create three threads and start them.\r\n" + - "The threads wait on AutoResetEvent #1, which was created\r\n" + - "in the signaled state, so the first thread is released.\r\n" + - "This puts AutoResetEvent #1 into the unsignaled state."); - Console::ReadLine(); - - for (int i = 1; i < 4; i++) - { - Thread^ t = gcnew Thread(gcnew ThreadStart(&ThreadProc)); - t->Name = "Thread_" + i; - t->Start(); - } - Thread::Sleep(250); - - for (int i = 0; i < 2; i++) - { - Console::WriteLine("Press Enter to release another thread."); - Console::ReadLine(); - event_1->Set(); - Thread::Sleep(250); - } - - Console::WriteLine("\r\nAll threads are now waiting on AutoResetEvent #2."); - for (int i = 0; i < 3; i++) - { - Console::WriteLine("Press Enter to release a thread."); - Console::ReadLine(); - event_2->Set(); - Thread::Sleep(250); - } - - // Visual Studio: Uncomment the following line. - //Console::Readline(); - } -}; - -void main() -{ - Example::Demo(); -} - -/* This example produces output similar to the following: - -Press Enter to create three threads and start them. -The threads wait on AutoResetEvent #1, which was created -in the signaled state, so the first thread is released. -This puts AutoResetEvent #1 into the unsignaled state. - -Thread_1 waits on AutoResetEvent #1. -Thread_1 is released from AutoResetEvent #1. -Thread_1 waits on AutoResetEvent #2. -Thread_3 waits on AutoResetEvent #1. -Thread_2 waits on AutoResetEvent #1. -Press Enter to release another thread. - -Thread_3 is released from AutoResetEvent #1. -Thread_3 waits on AutoResetEvent #2. -Press Enter to release another thread. - -Thread_2 is released from AutoResetEvent #1. -Thread_2 waits on AutoResetEvent #2. - -All threads are now waiting on AutoResetEvent #2. -Press Enter to release a thread. - -Thread_2 is released from AutoResetEvent #2. -Thread_2 ends. -Press Enter to release a thread. - -Thread_1 is released from AutoResetEvent #2. -Thread_1 ends. -Press Enter to release a thread. - -Thread_3 is released from AutoResetEvent #2. -Thread_3 ends. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp deleted file mode 100644 index 9545b8e2fae..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// -using namespace System; -using namespace System::Threading; -using namespace System::Security::AccessControl; -using namespace System::Security::Permissions; - -public ref class Example -{ -public: - [SecurityPermissionAttribute(SecurityAction::Demand,Flags=SecurityPermissionFlag::UnmanagedCode)] - static void Main() - { - // - String^ ewhName = L"EventWaitHandleExample5"; - - EventWaitHandle^ ewh = nullptr; - bool doesNotExist = false; - bool unauthorized = false; - - // The value of this variable is set by the event - // constructor. It is true if the named system event was - // created, and false if the named event already existed. - // - bool wasCreated; - - // Attempt to open the named event. - try - { - // Open the event with (EventWaitHandleRights.Synchronize - // | EventWaitHandleRights.Modify), to wait on and - // signal the named event. - // - ewh = EventWaitHandle::OpenExisting( ewhName ); - } - catch ( WaitHandleCannotBeOpenedException^ ) - { - Console::WriteLine( L"Named event does not exist." ); - doesNotExist = true; - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", ex->Message ); - unauthorized = true; - } - // - - // There are three cases: (1) The event does not exist. - // (2) The event exists, but the current user doesn't - // have access. (3) The event exists and the user has - // access. - // - if ( doesNotExist ) - { - // - // The event does not exist, so create it. - - // Create an access control list (ACL) that denies the - // current user the right to wait on or signal the - // event, but allows the right to read and change - // security information for the event. - // - String^ user = String::Concat( Environment::UserDomainName, L"\\", - Environment::UserName ); - EventWaitHandleSecurity^ ewhSec = gcnew EventWaitHandleSecurity; - //following constructor fails - EventWaitHandleAccessRule^ rule = gcnew EventWaitHandleAccessRule( - user, - static_cast( - EventWaitHandleRights::Synchronize | - EventWaitHandleRights::Modify), - AccessControlType::Deny ); - ewhSec->AddAccessRule( rule ); - - rule = gcnew EventWaitHandleAccessRule( user, - static_cast( - EventWaitHandleRights::ReadPermissions | - EventWaitHandleRights::ChangePermissions), - AccessControlType::Allow ); - ewhSec->AddAccessRule( rule ); - - // Create an EventWaitHandle object that represents - // the system event named by the constant 'ewhName', - // initially signaled, with automatic reset, and with - // the specified security access. The Boolean value that - // indicates creation of the underlying system object - // is placed in wasCreated. - // - ewh = gcnew EventWaitHandle( true, - EventResetMode::AutoReset, - ewhName, - wasCreated, - ewhSec ); - - // If the named system event was created, it can be - // used by the current instance of this program, even - // though the current user is denied access. The current - // program owns the event. Otherwise, exit the program. - // - if ( wasCreated ) - { - Console::WriteLine( L"Created the named event." ); - } - else - { - Console::WriteLine( L"Unable to create the event." ); - return; - } - // - } - else if ( unauthorized ) - { - // - // Open the event to read and change the access control - // security. The access control security defined above - // allows the current user to do this. - // - try - { - ewh = EventWaitHandle::OpenExisting( ewhName, - static_cast( - EventWaitHandleRights::ReadPermissions | - EventWaitHandleRights::ChangePermissions) ); - - // Get the current ACL. This requires - // EventWaitHandleRights.ReadPermissions. - EventWaitHandleSecurity^ ewhSec = ewh->GetAccessControl(); - String^ user = String::Concat( Environment::UserDomainName, L"\\", - Environment::UserName ); - - // First, the rule that denied the current user - // the right to enter and release the event must - // be removed. - EventWaitHandleAccessRule^ rule = gcnew EventWaitHandleAccessRule( - user, - static_cast( - EventWaitHandleRights::Synchronize | - EventWaitHandleRights::Modify), - AccessControlType::Deny ); - ewhSec->RemoveAccessRule( rule ); - - // Now grant the user the correct rights. - // - rule = gcnew EventWaitHandleAccessRule( user, - static_cast( - EventWaitHandleRights::Synchronize | - EventWaitHandleRights::Modify), - AccessControlType::Allow ); - ewhSec->AddAccessRule( rule ); - - // Update the ACL. This requires - // EventWaitHandleRights.ChangePermissions. - ewh->SetAccessControl( ewhSec ); - Console::WriteLine( L"Updated event security." ); - - // Open the event with (EventWaitHandleRights.Synchronize - // | EventWaitHandleRights.Modify), the rights required - // to wait on and signal the event. - // - ewh = EventWaitHandle::OpenExisting( ewhName ); - // - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unable to change permissions: {0}", - ex->Message ); - return; - } - - } - - // Wait on the event, and hold it until the program - // exits. - // - try - { - Console::WriteLine( L"Wait on the event." ); - ewh->WaitOne(); - Console::WriteLine( L"Event was signaled." ); - Console::WriteLine( L"Press the Enter key to signal the event and exit." ); - Console::ReadLine(); - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", ex->Message ); - } - finally - { - ewh->Set(); - } - } -}; - -int main() -{ - Example::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked CompareExchange0/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked CompareExchange0/CPP/source.cpp deleted file mode 100644 index 37370e944c5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked CompareExchange0/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - - -// -// This example demonstrates a thread-safe method that adds to a -// running total. It cannot be run directly. You can compile it -// as a library, or add the class to a project. -#using - -using namespace System::Threading; -public ref class ThreadSafe -{ -private: - - // totalValue contains a running total that can be updated - // by multiple threads. It must be protected from unsynchronized - // access. - int totalValue; - -public: - - property int Total - { - - // The Total property returns the running total. - int get() - { - return totalValue; - } - - } - - // AddToTotal safely adds a value to the running total. - int AddToTotal( int addend ) - { - int initialValue; - int computedValue; - do - { - - // Save the current running total in a local variable. - initialValue = totalValue; - - // Add the new value to the running total. - computedValue = initialValue + addend; - - // CompareExchange compares totalValue to initialValue. If - // they are not equal, then another thread has updated the - // running total since this loop started. CompareExchange - // does not update totalValue. CompareExchange returns the - // contents of totalValue, which do not equal initialValue, - // so the loop executes again. - } - while ( initialValue != Interlocked::CompareExchange( totalValue, computedValue, initialValue ) ); - - - // If no other thread updated the running total, then - // totalValue and initialValue are equal when CompareExchange - // compares them, and computedValue is stored in totalValue. - // CompareExchange returns the value that was in totalValue - // before the update, which is equal to initialValue, so the - // loop ends. - // The function returns computedValue, not totalValue, because - // totalValue could be changed by another thread between - // the time the loop ends and the function returns. - return computedValue; - } - -}; - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/CPP/class1.cpp deleted file mode 100644 index a04b9df75bd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/CPP/class1.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -const int numThreads = 10; -const int numThreadIterations = 5; -ref class MyInterlockedExchangeExampleClass -{ -public: - static void MyThreadProc() - { - for ( int i = 0; i < numThreadIterations; i++ ) - { - UseResource(); - - //Wait 1 second before next attempt. - Thread::Sleep( 1000 ); - - } - } - - -private: - //A simple method that denies reentrancy. - static bool UseResource() - { - - //0 indicates that the method is not in use. - if ( 0 == Interlocked::Exchange( usingResource, 1 ) ) - { - Console::WriteLine( " {0} acquired the lock", Thread::CurrentThread->Name ); - - //Code to access a resource that is not thread safe would go here. - //Simulate some work - Thread::Sleep( 500 ); - Console::WriteLine( " {0} exiting lock", Thread::CurrentThread->Name ); - - //Release the lock - Interlocked::Exchange( usingResource, 0 ); - return true; - } - else - { - Console::WriteLine( " {0} was denied the lock", Thread::CurrentThread->Name ); - return false; - } - } - - - //0 for false, 1 for true. - static int usingResource; -}; - -int main() -{ - Thread^ myThread; - Random^ rnd = gcnew Random; - for ( int i = 0; i < numThreads; i++ ) - { - myThread = gcnew Thread( gcnew ThreadStart( MyInterlockedExchangeExampleClass::MyThreadProc ) ); - myThread->Name = String::Format( "Thread {0}", i + 1 ); - - //Wait a random amount of time before starting next thread. - Thread::Sleep( rnd->Next( 0, 1000 ) ); - myThread->Start(); - - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/CPP/source.cpp deleted file mode 100644 index f89e7184409..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/CPP/source.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -ref class Example -{ -private: - // mre is used to block and release threads manually. It is - // created in the unsignaled state. - static ManualResetEvent^ mre = gcnew ManualResetEvent(false); - - static void ThreadProc() - { - String^ name = Thread::CurrentThread->Name; - - Console::WriteLine(name + " starts and calls mre->WaitOne()"); - - mre->WaitOne(); - - Console::WriteLine(name + " ends."); - } - -public: - static void Demo() - { - Console::WriteLine("\nStart 3 named threads that block on a ManualResetEvent:\n"); - - for(int i = 0; i <=2 ; i++) - { - Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc)); - t->Name = "Thread_" + i; - t->Start(); - } - - Thread::Sleep(500); - Console::WriteLine("\nWhen all three threads have started, press Enter to call Set()" + - "\nto release all the threads.\n"); - Console::ReadLine(); - - mre->Set(); - - Thread::Sleep(500); - Console::WriteLine("\nWhen a ManualResetEvent is signaled, threads that call WaitOne()" + - "\ndo not block. Press Enter to show this.\n"); - Console::ReadLine(); - - for(int i = 3; i <= 4; i++) - { - Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc)); - t->Name = "Thread_" + i; - t->Start(); - } - - Thread::Sleep(500); - Console::WriteLine("\nPress Enter to call Reset(), so that threads once again block" + - "\nwhen they call WaitOne().\n"); - Console::ReadLine(); - - mre->Reset(); - - // Start a thread that waits on the ManualResetEvent. - Thread^ t5 = gcnew Thread(gcnew ThreadStart(ThreadProc)); - t5->Name = "Thread_5"; - t5->Start(); - - Thread::Sleep(500); - Console::WriteLine("\nPress Enter to call Set() and conclude the demo."); - Console::ReadLine(); - - mre->Set(); - - // If you run this example in Visual Studio, uncomment the following line: - //Console::ReadLine(); - } -}; - -int main() -{ - Example::Demo(); -} - -/* This example produces output similar to the following: - -Start 3 named threads that block on a ManualResetEvent: - -Thread_0 starts and calls mre->WaitOne() -Thread_1 starts and calls mre->WaitOne() -Thread_2 starts and calls mre->WaitOne() - -When all three threads have started, press Enter to call Set() -to release all the threads. - - -Thread_2 ends. -Thread_1 ends. -Thread_0 ends. - -When a ManualResetEvent is signaled, threads that call WaitOne() -do not block. Press Enter to show this. - - -Thread_3 starts and calls mre->WaitOne() -Thread_3 ends. -Thread_4 starts and calls mre->WaitOne() -Thread_4 ends. - -Press Enter to call Reset(), so that threads once again block -when they call WaitOne(). - - -Thread_5 starts and calls mre->WaitOne() - -Press Enter to call Set() and conclude the demo. - -Thread_5 ends. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 1Arg Ctor Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 1Arg Ctor Example/CPP/class1.cpp deleted file mode 100644 index b46723cfa04..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 1Arg Ctor Example/CPP/class1.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -const int numIterations = 1; -const int numThreads = 3; - -ref class Test -{ -public: - - // Create a new Mutex. The creating thread owns the - // Mutex. - static Mutex^ mut = gcnew Mutex( true ); - static void MyThreadProc() - { - for ( int i = 0; i < numIterations; i++ ) - { - UseResource(); - - } - } - - -private: - - // This method represents a resource that must be synchronized - // so that only one thread at a time can enter. - static void UseResource() - { - - //Wait until it is OK to enter. - mut->WaitOne(); - Console::WriteLine( "{0} has entered protected the area", Thread::CurrentThread->Name ); - - // Place code to access non-reentrant resources here. - // Simulate some work. - Thread::Sleep( 500 ); - Console::WriteLine( "{0} is leaving protected the area\r\n", Thread::CurrentThread->Name ); - - // Release the Mutex. - mut->ReleaseMutex(); - } - -}; - -int main() -{ - - // Initialize the Mutex. - Mutex^ mut = Test::mut; - - // Create the threads that will use the protected resource. - for ( int i = 0; i < numThreads; i++ ) - { - Thread^ myThread = gcnew Thread( gcnew ThreadStart( Test::MyThreadProc ) ); - myThread->Name = String::Format( "Thread {0}", i + 1 ); - myThread->Start(); - - } - - // Wait one second before allowing other threads to - // acquire the Mutex. - Console::WriteLine( "Creating thread owns the Mutex." ); - Thread::Sleep( 1000 ); - Console::WriteLine( "Creating thread releases the Mutex.\r\n" ); - mut->ReleaseMutex(); -} -// The example displays output like the following: -// Creating thread owns the Mutex. -// Creating thread releases the Mutex. -// -// Thread1 has entered the protected area -// Thread1 is leaving the protected area -// -// Thread2 has entered the protected area -// Thread2 is leaving the protected area -// -// Thread3 has entered the protected area -// Thread3 is leaving the protected area -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 2Arg Ctor Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 2Arg Ctor Example/CPP/class1.cpp deleted file mode 100644 index 4079eedaa6e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 2Arg Ctor Example/CPP/class1.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -int main() -{ - // Create the named mutex. Only one system object named - // "MyMutex" can exist; the local Mutex object represents - // this system object, regardless of which process or thread - // caused "MyMutex" to be created. - Mutex^ m = gcnew Mutex( false,"MyMutex" ); - - // Try to gain control of the named mutex. If the mutex is - // controlled by another thread, wait for it to be released. - Console::WriteLine( "Waiting for the Mutex." ); - m->WaitOne(); - - // Keep control of the mutex until the user presses - // ENTER. - Console::WriteLine( "This application owns the mutex. " - "Press ENTER to release the mutex and exit." ); - Console::ReadLine(); - m->ReleaseMutex(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 3Arg Ctor Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 3Arg Ctor Example/CPP/class1.cpp deleted file mode 100644 index a8d967c7296..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 3Arg Ctor Example/CPP/class1.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// -// This example shows how a named mutex is used to signal between -// processes or threads. -// Run this program from two (or more) command windows. Each process -// creates a Mutex object that represents the named mutex "MyMutex". -// The named mutex is a system object whose lifetime is bounded by the -// lifetimes of the Mutex objects that represent it. The named mutex -// is created when the first process creates its local Mutex; in this -// example, the named mutex is owned by the first process. The named -// mutex is destroyed when all the Mutex objects that represent it -// have been released. -// The second process (and any subsequent process) waits for earlier -// processes to release the named mutex. -using namespace System; -using namespace System::Threading; -int main() -{ - - // Set this variable to false if you do not want to request - // initial ownership of the named mutex. - bool requestInitialOwnership = true; - bool mutexWasCreated; - - // Request initial ownership of the named mutex by passing - // true for the first parameter. Only one system object named - // "MyMutex" can exist; the local Mutex object represents - // this system object. If "MyMutex" is created by this call, - // then mutexWasCreated contains true; otherwise, it contains - // false. - Mutex^ m = gcnew Mutex( requestInitialOwnership, "MyMutex", mutexWasCreated ); - - // This thread owns the mutex only if it both requested - // initial ownership and created the named mutex. Otherwise, - // it can request the named mutex by calling WaitOne. - if ( !(requestInitialOwnership && mutexWasCreated) ) - { - Console::WriteLine( "Waiting for the named mutex." ); - m->WaitOne(); - } - - - // Once the process has gained control of the named mutex, - // hold onto it until the user presses ENTER. - Console::WriteLine( "This process owns the named mutex. " - "Press ENTER to release the mutex and exit." ); - Console::ReadLine(); - - // Call ReleaseMutex to allow other threads to gain control - // of the named mutex. If you keep a reference to the local - // Mutex, you can call WaitOne to request control of the - // named mutex. - m->ReleaseMutex(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/CPP/class1.cpp deleted file mode 100644 index 958035c2e03..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/CPP/class1.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -// This example shows how a Mutex is used to synchronize access -// to a protected resource. Unlike Monitor, Mutex can be used with -// WaitHandle.WaitAll and WaitAny, and can be passed across -// AppDomain boundaries. -using namespace System; -using namespace System::Threading; -const int numIterations = 1; -const int numThreads = 3; -ref class Test -{ -public: - - // Create a new Mutex. The creating thread does not own the - // Mutex. - static Mutex^ mut = gcnew Mutex; - static void MyThreadProc() - { - for ( int i = 0; i < numIterations; i++ ) - { - UseResource(); - - } - } - - -private: - - // This method represents a resource that must be synchronized - // so that only one thread at a time can enter. - static void UseResource() - { - - //Wait until it is OK to enter. - mut->WaitOne(); - Console::WriteLine( "{0} has entered protected the area", Thread::CurrentThread->Name ); - - // Place code to access non-reentrant resources here. - // Simulate some work. - Thread::Sleep( 500 ); - Console::WriteLine( "{0} is leaving protected the area\r\n", Thread::CurrentThread->Name ); - - // Release the Mutex. - mut->ReleaseMutex(); - } - -}; - -int main() -{ - - // Create the threads that will use the protected resource. - for ( int i = 0; i < numThreads; i++ ) - { - Thread^ myThread = gcnew Thread( gcnew ThreadStart( Test::MyThreadProc ) ); - myThread->Name = String::Format( "Thread {0}", i + 1 ); - myThread->Start(); - - } - - // The main thread exits, but the application continues to - // run until all foreground threads have exited. -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp deleted file mode 100644 index 26673315e5e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// -using namespace System; -using namespace System::Threading; -using namespace System::Security::AccessControl; -using namespace System::Security::Permissions; - -public ref class Example -{ -public: - [SecurityPermissionAttribute(SecurityAction::Demand,Flags=SecurityPermissionFlag::UnmanagedCode)] - static void Main() - { - // - String^ mutexName = L"MutexExample4"; - - Mutex^ m = nullptr; - bool doesNotExist = false; - bool unauthorized = false; - - // The value of this variable is set by the mutex - // constructor. It is true if the named system mutex was - // created, and false if the named mutex already existed. - // - bool mutexWasCreated = false; - - // Attempt to open the named mutex. - try - { - // Open the mutex with (MutexRights.Synchronize | - // MutexRights.Modify), to enter and release the - // named mutex. - // - m = Mutex::OpenExisting( mutexName ); - } - catch ( WaitHandleCannotBeOpenedException^ ) - { - Console::WriteLine( L"Mutex does not exist." ); - doesNotExist = true; - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", ex->Message ); - unauthorized = true; - } - // - - // There are three cases: (1) The mutex does not exist. - // (2) The mutex exists, but the current user doesn't - // have access. (3) The mutex exists and the user has - // access. - // - if ( doesNotExist ) - { - // - // The mutex does not exist, so create it. - // Create an access control list (ACL) that denies the - // current user the right to enter or release the - // mutex, but allows the right to read and change - // security information for the mutex. - // - String^ user = String::Concat( Environment::UserDomainName, L"\\", - Environment::UserName ); - MutexSecurity^ mSec = gcnew MutexSecurity; - - MutexAccessRule^ rule = gcnew MutexAccessRule( user, - static_cast( - MutexRights::Synchronize | - MutexRights::Modify), - AccessControlType::Deny ); - mSec->AddAccessRule( rule ); - - rule = gcnew MutexAccessRule( user, - static_cast( - MutexRights::ReadPermissions | - MutexRights::ChangePermissions), - AccessControlType::Allow ); - mSec->AddAccessRule( rule ); - - // Create a Mutex object that represents the system - // mutex named by the constant 'mutexName', with - // initial ownership for this thread, and with the - // specified security access. The Boolean value that - // indicates creation of the underlying system object - // is placed in mutexWasCreated. - // - m = gcnew Mutex( true,mutexName, mutexWasCreated,mSec ); - - // If the named system mutex was created, it can be - // used by the current instance of this program, even - // though the current user is denied access. The current - // program owns the mutex. Otherwise, exit the program. - // - if ( mutexWasCreated ) - { - Console::WriteLine( L"Created the mutex." ); - } - else - { - Console::WriteLine( L"Unable to create the mutex." ); - return; - } - // - } - else if ( unauthorized ) - { - // - // Open the mutex to read and change the access control - // security. The access control security defined above - // allows the current user to do this. - // - try - { - m = Mutex::OpenExisting( mutexName, - static_cast( - MutexRights::ReadPermissions | - MutexRights::ChangePermissions) ); - - // Get the current ACL. This requires - // MutexRights.ReadPermissions. - MutexSecurity^ mSec = m->GetAccessControl(); - - String^ user = String::Concat( Environment::UserDomainName, - L"\\", Environment::UserName ); - - // First, the rule that denied the current user - // the right to enter and release the mutex must - // be removed. - MutexAccessRule^ rule = gcnew MutexAccessRule( user, - static_cast( - MutexRights::Synchronize | - MutexRights::Modify), - AccessControlType::Deny ); - mSec->RemoveAccessRule( rule ); - - // Now grant the user the correct rights. - // - rule = gcnew MutexAccessRule( user, - static_cast( - MutexRights::Synchronize | - MutexRights::Modify), - AccessControlType::Allow ); - mSec->AddAccessRule( rule ); - - // Update the ACL. This requires - // MutexRights.ChangePermissions. - m->SetAccessControl( mSec ); - - Console::WriteLine( L"Updated mutex security." ); - - // Open the mutex with (MutexRights.Synchronize - // | MutexRights.Modify), the rights required to - // enter and release the mutex. - // - m = Mutex::OpenExisting( mutexName ); - // - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( - L"Unable to change permissions: {0}", ex->Message ); - return; - } - } - - // If this program created the mutex, it already owns - // the mutex. - // - if ( !mutexWasCreated ) - { - // Enter the mutex, and hold it until the program - // exits. - // - try - { - Console::WriteLine( L"Wait for the mutex." ); - m->WaitOne(); - Console::WriteLine( L"Entered the mutex." ); - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", - ex->Message ); - } - } - - Console::WriteLine( L"Press the Enter key to exit." ); - Console::ReadLine(); - m->ReleaseMutex(); - m->Dispose(); - } -}; - -int main() -{ - Example::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp deleted file mode 100644 index 6395c7d937d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -namespace SystemThreadingExample -{ - public ref class Work - { - public: - void StartThreads() - { - // Start a thread that calls a parameterized static method. - Thread^ newThread = gcnew - Thread(gcnew ParameterizedThreadStart(Work::DoWork)); - newThread->Start(42); - - // Start a thread that calls a parameterized instance method. - Work^ someWork = gcnew Work; - newThread = gcnew Thread( - gcnew ParameterizedThreadStart(someWork, - &Work::DoMoreWork)); - newThread->Start("The answer."); - } - - static void DoWork(Object^ data) - { - Console::WriteLine("Static thread procedure. Data='{0}'", - data); - } - - void DoMoreWork(Object^ data) - { - Console::WriteLine("Instance thread procedure. Data='{0}'", - data); - } - }; -} - -//Entry point of example application -int main() -{ - SystemThreadingExample::Work^ samplework = - gcnew SystemThreadingExample::Work(); - samplework->StartThreads(); -} -// This example displays output like the following: -// Static thread procedure. Data='42' -// Instance thread procedure. Data='The answer.' -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/CPP/source.cpp deleted file mode 100644 index 36560d92fa5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -int main() -{ - ReaderWriterLock^ rwLock = gcnew ReaderWriterLock; - rwLock->AcquireWriterLock( Timeout::Infinite ); - rwLock->AcquireReaderLock( Timeout::Infinite ); - if ( rwLock->IsReaderLockHeld ) - { - Console::WriteLine( "Reader lock held." ); - rwLock->ReleaseReaderLock(); - } - else - if ( rwLock->IsWriterLockHeld ) - { - Console::WriteLine( "Writer lock held." ); - rwLock->ReleaseWriterLock(); - } - else - { - Console::WriteLine( "No locks held." ); - } - - - if ( rwLock->IsReaderLockHeld ) - { - Console::WriteLine( "Reader lock held." ); - rwLock->ReleaseReaderLock(); - } - else - if ( rwLock->IsWriterLockHeld ) - { - Console::WriteLine( "Writer lock held." ); - rwLock->ReleaseWriterLock(); - } - else - { - Console::WriteLine( "No locks held." ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp deleted file mode 100644 index 1aca8464071..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// -// This example shows a ReaderWriterLock protecting a shared -// resource that is read concurrently and written exclusively -// by multiple threads. -// -// The complete code is located in the ReaderWriterLock -// class topic. -using namespace System; -using namespace System::Threading; -public ref class Test -{ -public: - - // Declaring the ReaderWriterLock at the class level - // makes it visible to all threads. - static ReaderWriterLock^ rwl = gcnew ReaderWriterLock; - - // For this example, the shared resource protected by the - // ReaderWriterLock is just an integer. - static int resource = 0; - - // - literal int numThreads = 26; - static bool running = true; - - // Statistics. - static int readerTimeouts = 0; - static int writerTimeouts = 0; - static int reads = 0; - static int writes = 0; - static void ThreadProc() - { - Random^ rnd = gcnew Random; - - // As long as a thread runs, it randomly selects - // various ways to read and write from the shared - // resource. Each of the methods demonstrates one - // or more features of ReaderWriterLock. - while ( running ) - { - double action = rnd->NextDouble(); - if ( action < .8 ) - ReadFromResource( 10 ); - else - if ( action < .81 ) - ReleaseRestore( rnd, 50 ); - else - if ( action < .90 ) - UpgradeDowngrade( rnd, 100 ); - else - WriteToResource( rnd, 100 ); - } - } - - - // - // Shows how to request and release a reader lock, and - // how to handle time-outs. - static void ReadFromResource( int timeOut ) - { - try - { - rwl->AcquireReaderLock( timeOut ); - try - { - - // It is safe for this thread to read from - // the shared resource. - Display( String::Format( "reads resource value {0}", resource ) ); - Interlocked::Increment( reads ); - } - finally - { - - // Ensure that the lock is released. - rwl->ReleaseReaderLock(); - } - - } - catch ( ApplicationException^ ) - { - - // The reader lock request timed out. - Interlocked::Increment( readerTimeouts ); - } - - } - - - // - // - // Shows how to request and release the writer lock, and - // how to handle time-outs. - static void WriteToResource( Random^ rnd, int timeOut ) - { - try - { - rwl->AcquireWriterLock( timeOut ); - try - { - - // It is safe for this thread to read or write - // from the shared resource. - resource = rnd->Next( 500 ); - Display( String::Format( "writes resource value {0}", resource ) ); - Interlocked::Increment( writes ); - } - finally - { - - // Ensure that the lock is released. - rwl->ReleaseWriterLock(); - } - - } - catch ( ApplicationException^ ) - { - - // The writer lock request timed out. - Interlocked::Increment( writerTimeouts ); - } - - } - - - // - // - // Shows how to request a reader lock, upgrade the - // reader lock to the writer lock, and downgrade to a - // reader lock again. - static void UpgradeDowngrade( Random^ rnd, int timeOut ) - { - try - { - rwl->AcquireReaderLock( timeOut ); - try - { - - // It is safe for this thread to read from - // the shared resource. - Display( String::Format( "reads resource value {0}", resource ) ); - Interlocked::Increment( reads ); - - // If it is necessary to write to the resource, - // you must either release the reader lock and - // then request the writer lock, or upgrade the - // reader lock. Note that upgrading the reader lock - // puts the thread in the write queue, behind any - // other threads that might be waiting for the - // writer lock. - try - { - LockCookie lc = rwl->UpgradeToWriterLock( timeOut ); - try - { - - // It is safe for this thread to read or write - // from the shared resource. - resource = rnd->Next( 500 ); - Display( String::Format( "writes resource value {0}", resource ) ); - Interlocked::Increment( writes ); - } - finally - { - - // Ensure that the lock is released. - rwl->DowngradeFromWriterLock( lc ); - } - - } - catch ( ApplicationException^ ) - { - - // The upgrade request timed out. - Interlocked::Increment( writerTimeouts ); - } - - - // When the lock has been downgraded, it is - // still safe to read from the resource. - Display( String::Format( "reads resource value {0}", resource ) ); - Interlocked::Increment( reads ); - } - finally - { - - // Ensure that the lock is released. - rwl->ReleaseReaderLock(); - } - - } - catch ( ApplicationException^ ) - { - - // The reader lock request timed out. - Interlocked::Increment( readerTimeouts ); - } - - } - - - // - // - // Shows how to release all locks and later restore - // the lock state. Shows how to use sequence numbers - // to determine whether another thread has obtained - // a writer lock since this thread last accessed the - // resource. - static void ReleaseRestore( Random^ rnd, int timeOut ) - { - int lastWriter; - try - { - rwl->AcquireReaderLock( timeOut ); - try - { - - // It is safe for this thread to read from - // the shared resource. Cache the value. (You - // might do this if reading the resource is - // an expensive operation.) - int resourceValue = resource; - Display( String::Format( "reads resource value {0}", resourceValue ) ); - Interlocked::Increment( reads ); - - // Save the current writer sequence number. - lastWriter = rwl->WriterSeqNum; - - // Release the lock, and save a cookie so the - // lock can be restored later. - LockCookie lc = rwl->ReleaseLock(); - - // Wait for a random interval (up to a - // quarter of a second), and then restore - // the previous state of the lock. Note that - // there is no timeout on the Restore method. - Thread::Sleep( rnd->Next( 250 ) ); - rwl->RestoreLock( lc ); - - // Check whether other threads obtained the - // writer lock in the interval. If not, then - // the cached value of the resource is still - // valid. - if ( rwl->AnyWritersSince( lastWriter ) ) - { - resourceValue = resource; - Interlocked::Increment( reads ); - Display( String::Format( "resource has changed {0}", resourceValue ) ); - } - else - { - Display( String::Format( "resource has not changed {0}", resourceValue ) ); - } - } - finally - { - - // Ensure that the lock is released. - rwl->ReleaseReaderLock(); - } - - } - catch ( ApplicationException^ ) - { - - // The reader lock request timed out. - Interlocked::Increment( readerTimeouts ); - } - - } - - - // - // Helper method briefly displays the most recent - // thread action. Comment out calls to Display to - // get a better idea of throughput. - static void Display( String^ msg ) - { - Console::Write( "Thread {0} {1}. \r", Thread::CurrentThread->Name, msg ); - } - - // -}; - - -// -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // Start a series of threads. Each thread randomly - // performs reads and writes on the shared resource. - array^t = gcnew array(Test::numThreads); - for ( int i = 0; i < Test::numThreads; i++ ) - { - t[ i ] = gcnew Thread( gcnew ThreadStart( Test::ThreadProc ) ); - t[ i ]->Name = gcnew String( Convert::ToChar( i + 65 ),1 ); - t[ i ]->Start(); - if ( i > 10 ) - Thread::Sleep( 300 ); - - } - - // Tell the threads to shut down, then wait until they all - // finish. - Test::running = false; - for ( int i = 0; i < Test::numThreads; i++ ) - { - t[ i ]->Join(); - - } - - // Display statistics. - Console::WriteLine( "\r\n {0} reads, {1} writes, {2} reader time-outs, {3} writer time-outs.", Test::reads, Test::writes, Test::readerTimeouts, Test::writerTimeouts ); - Console::WriteLine( "Press ENTER to exit." ); - Console::ReadLine(); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 3/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 3/CPP/source.cpp deleted file mode 100644 index c9829906328..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 3/CPP/source.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -#using -using namespace System; -using namespace System::Threading; - -public ref class Example -{ -public: - static void main() - { - // Create a Semaphore object that represents the named - // system semaphore "SemaphoreExample3". The semaphore has a - // maximum count of five. The initial count is also five. - // There is no point in using a smaller initial count, - // because the initial count is not used if this program - // doesn't create the named system semaphore, and with - // this method overload there is no way to tell. Thus, this - // program assumes that it is competing with other - // programs for the semaphore. - // - Semaphore^ sem = gcnew Semaphore( 5,5,L"SemaphoreExample3" ); - - // Attempt to enter the semaphore three times. If another - // copy of this program is already running, only the first - // two requests can be satisfied. The third blocks. Note - // that in a real application, timeouts should be used - // on the WaitOne calls, to avoid deadlocks. - // - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore once." ); - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore twice." ); - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore three times." ); - - // The thread executing this program has entered the - // semaphore three times. If a second copy of the program - // is run, it will block until this program releases the - // semaphore at least once. - // - Console::WriteLine( L"Enter the number of times to call Release." ); - int n; - if ( Int32::TryParse( Console::ReadLine(),n ) ) - { - sem->Release( n ); - } - - int remaining = 3 - n; - if ( remaining > 0 ) - { - Console::WriteLine( L"Press Enter to release the remaining " - L"count ({0}) and exit the program.", remaining ); - Console::ReadLine(); - sem->Release( remaining ); - } - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 4/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 4/CPP/source.cpp deleted file mode 100644 index a51b308ac9e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 4/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -#using -using namespace System; -using namespace System::Threading; - -public ref class Example -{ -public: - static void main() - { - // The value of this variable is set by the semaphore - // constructor. It is true if the named system semaphore was - // created, and false if the named semaphore already existed. - // - bool semaphoreWasCreated; - - // Create a Semaphore object that represents the named - // system semaphore "SemaphoreExample". The semaphore has a - // maximum count of five, and an initial count of two. The - // Boolean value that indicates creation of the underlying - // system object is placed in semaphoreWasCreated. - // - Semaphore^ sem = gcnew Semaphore( 2,5,L"SemaphoreExample", - semaphoreWasCreated ); - if ( semaphoreWasCreated ) - { - // If the named system semaphore was created, its count is - // set to the initial count requested in the constructor. - // In effect, the current thread has entered the semaphore - // three times. - // - Console::WriteLine( L"Entered the semaphore three times." ); - } - else - { - // If the named system semaphore was not created, - // attempt to enter it three times. If another copy of - // this program is already running, only the first two - // requests can be satisfied. The third blocks. - // - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore once." ); - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore twice." ); - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore three times." ); - } - - // The thread executing this program has entered the - // semaphore three times. If a second copy of the program - // is run, it will block until this program releases the - // semaphore at least once. - // - Console::WriteLine( L"Enter the number of times to call Release." ); - int n; - if ( Int32::TryParse( Console::ReadLine(), n ) ) - { - sem->Release( n ); - } - - int remaining = 3 - n; - if ( remaining > 0 ) - { - Console::WriteLine( L"Press Enter to release the remaining " - L"count ({0}) and exit the program.", remaining ); - Console::ReadLine(); - sem->Release( remaining ); - } - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp deleted file mode 100644 index 471a8d1e8b1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp +++ /dev/null @@ -1,186 +0,0 @@ -// -#using -using namespace System; -using namespace System::Threading; -using namespace System::Security::AccessControl; -using namespace System::Security::Permissions; - -public ref class Example -{ -public: - [SecurityPermissionAttribute(SecurityAction::Demand, Flags = SecurityPermissionFlag::UnmanagedCode)] - static void main() - { - // - String^ semaphoreName = L"SemaphoreExample5"; - - Semaphore^ sem = nullptr; - bool doesNotExist = false; - bool unauthorized = false; - - // Attempt to open the named semaphore. - try - { - // Open the semaphore with (SemaphoreRights.Synchronize - // | SemaphoreRights.Modify), to enter and release the - // named semaphore. - // - sem = Semaphore::OpenExisting( semaphoreName ); - } - catch ( WaitHandleCannotBeOpenedException^ ex ) - { - Console::WriteLine( L"Semaphore does not exist." ); - doesNotExist = true; - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", ex->Message ); - unauthorized = true; - } - // - - // There are three cases: (1) The semaphore does not exist. - // (2) The semaphore exists, but the current user doesn't - // have access. (3) The semaphore exists and the user has - // access. - // - if ( doesNotExist ) - { - // - // The semaphore does not exist, so create it. - // - // The value of this variable is set by the semaphore - // constructor. It is true if the named system semaphore was - // created, and false if the named semaphore already existed. - // - bool semaphoreWasCreated; - - // Create an access control list (ACL) that denies the - // current user the right to enter or release the - // semaphore, but allows the right to read and change - // security information for the semaphore. - // - String^ user = String::Concat( Environment::UserDomainName, - L"\\", Environment::UserName ); - SemaphoreSecurity^ semSec = gcnew SemaphoreSecurity; - - SemaphoreAccessRule^ rule = gcnew SemaphoreAccessRule( user, - static_cast( - SemaphoreRights::Synchronize | - SemaphoreRights::Modify ), - AccessControlType::Deny ); - semSec->AddAccessRule( rule ); - - rule = gcnew SemaphoreAccessRule( user, - static_cast( - SemaphoreRights::ReadPermissions | - SemaphoreRights::ChangePermissions ), - AccessControlType::Allow ); - semSec->AddAccessRule( rule ); - - // Create a Semaphore object that represents the system - // semaphore named by the constant 'semaphoreName', with - // maximum count three, initial count three, and the - // specified security access. The Boolean value that - // indicates creation of the underlying system object is - // placed in semaphoreWasCreated. - // - sem = gcnew Semaphore( 3,3,semaphoreName,semaphoreWasCreated,semSec ); - - // If the named system semaphore was created, it can be - // used by the current instance of this program, even - // though the current user is denied access. The current - // program enters the semaphore. Otherwise, exit the - // program. - // - if ( semaphoreWasCreated ) - { - Console::WriteLine( L"Created the semaphore." ); - } - else - { - Console::WriteLine( L"Unable to create the semaphore." ); - return; - } - // - - } - else if ( unauthorized ) - { - // - // Open the semaphore to read and change the access - // control security. The access control security defined - // above allows the current user to do this. - // - try - { - sem = Semaphore::OpenExisting( semaphoreName, - static_cast( - SemaphoreRights::ReadPermissions | - SemaphoreRights::ChangePermissions )); - - // Get the current ACL. This requires - // SemaphoreRights.ReadPermissions. - SemaphoreSecurity^ semSec = sem->GetAccessControl(); - - String^ user = String::Concat( Environment::UserDomainName, - L"\\", Environment::UserName ); - - // First, the rule that denied the current user - // the right to enter and release the semaphore must - // be removed. - SemaphoreAccessRule^ rule = gcnew SemaphoreAccessRule( user, - static_cast( - SemaphoreRights::Synchronize | - SemaphoreRights::Modify ), - AccessControlType::Deny ); - semSec->RemoveAccessRule( rule ); - - // Now grant the user the correct rights. - // - rule = gcnew SemaphoreAccessRule( user, - static_cast( - SemaphoreRights::Synchronize | - SemaphoreRights::Modify ), - AccessControlType::Allow ); - semSec->AddAccessRule( rule ); - - // Update the ACL. This requires - // SemaphoreRights.ChangePermissions. - sem->SetAccessControl( semSec ); - - Console::WriteLine( L"Updated semaphore security." ); - - // Open the semaphore with (SemaphoreRights.Synchronize - // | SemaphoreRights.Modify), the rights required to - // enter and release the semaphore. - // - sem = Semaphore::OpenExisting( semaphoreName ); - // - - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unable to change permissions: {0}", ex->Message ); - return; - } - } - - // Enter the semaphore, and hold it until the program - // exits. - // - try - { - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore." ); - Console::WriteLine( L"Press the Enter key to exit." ); - Console::ReadLine(); - sem->Release(); - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", ex->Message ); - } - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp deleted file mode 100644 index 13cb5b616e3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -#using -using namespace System; -using namespace System::Threading; - -public ref class Example -{ -private: - // A semaphore that simulates a limited resource pool. - // - static Semaphore^ _pool; - - // A padding interval to make the output more orderly. - static int _padding; - -public: - static void Main() - { - // Create a semaphore that can satisfy up to three - // concurrent requests. Use an initial count of zero, - // so that the entire semaphore count is initially - // owned by the main program thread. - // - _pool = gcnew Semaphore( 0,3 ); - - // Create and start five numbered threads. - // - for ( int i = 1; i <= 5; i++ ) - { - Thread^ t = gcnew Thread( - gcnew ParameterizedThreadStart( Worker ) ); - - // Start the thread, passing the number. - // - t->Start( i ); - } - - // Wait for half a second, to allow all the - // threads to start and to block on the semaphore. - // - Thread::Sleep( 500 ); - - // The main thread starts out holding the entire - // semaphore count. Calling Release(3) brings the - // semaphore count back to its maximum value, and - // allows the waiting threads to enter the semaphore, - // up to three at a time. - // - Console::WriteLine( L"Main thread calls Release(3)." ); - _pool->Release( 3 ); - - Console::WriteLine( L"Main thread exits." ); - } - -private: - static void Worker( Object^ num ) - { - // Each worker thread begins by requesting the - // semaphore. - Console::WriteLine( L"Thread {0} begins and waits for the semaphore.", num ); - _pool->WaitOne(); - - // A padding interval to make the output more orderly. - int padding = Interlocked::Add( _padding, 100 ); - - Console::WriteLine( L"Thread {0} enters the semaphore.", num ); - - // The thread's "work" consists of sleeping for - // about a second. Each thread "works" a little - // longer, just to make the output more orderly. - // - Thread::Sleep( 1000 + padding ); - - Console::WriteLine( L"Thread {0} releases the semaphore.", num ); - Console::WriteLine( L"Thread {0} previous semaphore count: {1}", - num, _pool->Release() ); - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.SemaphoreFullException/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.SemaphoreFullException/CPP/source.cpp deleted file mode 100644 index 91f6e6c03f5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.SemaphoreFullException/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -using namespace System; -using namespace System::Threading; - -public ref class Example -{ -private: - // A semaphore that can satisfy at most two concurrent - // requests. - // - static Semaphore^ _pool = gcnew Semaphore( 2,2 ); - -public: - static void main() - { - // Create and start two threads, A and B. - // - Thread^ tA = gcnew Thread( gcnew ThreadStart( ThreadA ) ); - tA->Start(); - - Thread^ tB = gcnew Thread( gcnew ThreadStart( ThreadB ) ); - tB->Start(); - } - -private: - static void ThreadA() - { - // Thread A enters the semaphore and simulates a task - // that lasts a second. - // - _pool->WaitOne(); - Console::WriteLine( L"Thread A entered the semaphore." ); - - Thread::Sleep( 1000 ); - - try - { - _pool->Release(); - Console::WriteLine( L"Thread A released the semaphore." ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"Thread A: {0}", ex->Message ); - } - } - - static void ThreadB() - { - // Thread B simulates a task that lasts half a second, - // then enters the semaphore. - // - Thread::Sleep( 500 ); - - _pool->WaitOne(); - Console::WriteLine( L"Thread B entered the semaphore." ); - - // Due to a programming error, Thread B releases the - // semaphore twice. To fix the program, delete one line. - _pool->Release(); - _pool->Release(); - Console::WriteLine( L"Thread B exits successfully." ); - } -}; -/* This code example produces the following output: - -Thread A entered the semaphore. -Thread B entered the semaphore. -Thread B exits successfully. -Thread A: Adding the given count to the semaphore would cause it to exceed its maximum count. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/CPP/source.cpp deleted file mode 100644 index 4ae633572bc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Test -{ -private: - Test(){} - - -public: - static void TestMethod() - { - try - { - while ( true ) - { - Console::WriteLine( "New thread running." ); - Thread::Sleep( 1000 ); - } - } - catch ( ThreadAbortException^ abortException ) - { - Console::WriteLine( dynamic_cast(abortException->ExceptionState) ); - } - - } - -}; - -int main() -{ - Thread^ newThread = gcnew Thread( gcnew ThreadStart( &Test::TestMethod ) ); - newThread->Start(); - Thread::Sleep( 1000 ); - - // Abort newThread. - Console::WriteLine( "Main aborting new thread." ); - newThread->Abort( "Information from main." ); - - // Wait for the thread to terminate. - newThread->Join(); - Console::WriteLine( "New thread terminated - main exiting." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/CPP/source.cpp deleted file mode 100644 index 99ee37687eb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -using namespace System::Threading; - -public ref class MyUtility -{ -public: - void PerformTask() - { - // Code in this region can be aborted without affecting - // other tasks. - // - Thread::BeginCriticalRegion(); - // - // The host might decide to unload the application domain - // if a failure occurs in this code region. - // - Thread::EndCriticalRegion(); - // - // Code in this region can be aborted without affecting - // other tasks. - } -}; -// - -int main() {} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/CPP/source.cpp deleted file mode 100644 index 2fd262cc0fa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -using namespace System::Threading; -using namespace System::Security::Permissions; - -public ref class MyUtility -{ -public: - [SecurityPermissionAttribute(SecurityAction::Demand, ControlThread=true)] - void PerformTask() - { - // Code that does not have thread affinity goes here. - // - Thread::BeginThreadAffinity(); - // - // Code that has thread affinity goes here. - // - Thread::EndThreadAffinity(); - // - // More code that does not have thread affinity. - } -}; -// - -int main() {} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Culture/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Culture/CPP/source.cpp deleted file mode 100644 index e91e5179e09..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Culture/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Threading; -using namespace System::Windows::Forms; -ref class UICulture: public Form -{ -public: - UICulture() - { - - // Set the user interface to display in the - // same culture as that set in Control Panel. - Thread::CurrentThread->CurrentUICulture = Thread::CurrentThread->CurrentCulture; - - // Add additional code. - } -}; - - -int main() -{ - Application::Run( gcnew UICulture ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.CurrentPrincipal/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.CurrentPrincipal/CPP/source.cpp deleted file mode 100644 index 1ae83042eb2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.CurrentPrincipal/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Security::Principal; -using namespace System::Threading; - -int main() -{ - array^rolesArray = {"managers","executives"}; - try - { - - // Set the principal to a new generic principal. - Thread::CurrentPrincipal = gcnew GenericPrincipal( gcnew GenericIdentity( "Bob","Passport" ),rolesArray ); - } - catch ( SecurityException^ secureException ) - { - Console::WriteLine( "{0}: Permission to set Principal " - "is denied.", secureException->GetType()->Name ); - } - - IPrincipal^ threadPrincipal = Thread::CurrentPrincipal; - Console::WriteLine( "Name: {0}\nIsAuthenticated: {1}" - "\nAuthenticationType: {2}", threadPrincipal->Identity->Name, threadPrincipal->Identity->IsAuthenticated.ToString(), threadPrincipal->Identity->AuthenticationType ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/CPP/source.cpp deleted file mode 100644 index 88a93c82f9d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Slot -{ -private: - static Random^ randomGenerator; - static LocalDataStoreSlot^ localSlot; - static Slot() - { - randomGenerator = gcnew Random; - localSlot = Thread::AllocateDataSlot(); - } - - -public: - static void SlotTest() - { - - // Set different data in each thread's data slot. - Thread::SetData( localSlot, randomGenerator->Next( 1, 200 ) ); - - // Write the data from each thread's data slot. - Console::WriteLine( "Data in thread_{0}'s data slot: {1,3}", AppDomain::GetCurrentThreadId().ToString(), Thread::GetData( localSlot )->ToString() ); - - // Allow other threads time to execute SetData to show - // that a thread's data slot is unique to the thread. - Thread::Sleep( 1000 ); - Console::WriteLine( "Data in thread_{0}'s data slot: {1,3}", AppDomain::GetCurrentThreadId().ToString(), Thread::GetData( localSlot )->ToString() ); - } - -}; - -int main() -{ - array^newThreads = gcnew array(4); - for ( int i = 0; i < newThreads->Length; i++ ) - { - newThreads[ i ] = gcnew Thread( gcnew ThreadStart( &Slot::SlotTest ) ); - newThreads[ i ]->Start(); - - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp deleted file mode 100644 index 7e368cd0a1c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -ref class ThreadData -{ -private: - [ThreadStatic] - static int threadSpecificData; - -public: - static void ThreadStaticDemo() - { - // Store the managed thread id for each thread in the static - // variable. - threadSpecificData = Thread::CurrentThread->ManagedThreadId; - - // Allow other threads time to execute the same code, to show - // that the static data is unique to each thread. - Thread::Sleep( 1000 ); - - // Display the static data. - Console::WriteLine( "Data for managed thread {0}: {1}", - Thread::CurrentThread->ManagedThreadId, threadSpecificData ); - } -}; - -int main() -{ - for ( int i = 0; i < 3; i++ ) - { - Thread^ newThread = - gcnew Thread( gcnew ThreadStart( ThreadData::ThreadStaticDemo )); - newThread->Start(); - } -} - -/* This code example produces output similar to the following: - -Data for managed thread 4: 4 -Data for managed thread 5: 5 -Data for managed thread 3: 3 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Domain/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Domain/CPP/source.cpp deleted file mode 100644 index 497071f1d0f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Domain/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Test -{ -private: - Test(){} - - -public: - static void ThreadMethod() - { - Console::WriteLine( "Thread {0} started in {1} with AppDomainID = {2}.", AppDomain::GetCurrentThreadId().ToString(), Thread::GetDomain()->FriendlyName, Thread::GetDomainID().ToString() ); - } - -}; - -int main() -{ - Thread^ newThread = gcnew Thread( gcnew ThreadStart( &Test::ThreadMethod ) ); - newThread->Start(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp deleted file mode 100644 index 533813e424f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Permissions; -using namespace System::Threading; - -ref class StayAwake -{ -private: - bool sleepSwitch; - -public: - - property bool SleepSwitch - { - void set( bool value ) - { - sleepSwitch = value; - } - - } - StayAwake() - { - sleepSwitch = false; - } - - void ThreadMethod() - { - Console::WriteLine( "newThread is executing ThreadMethod." ); - while ( !sleepSwitch ) - { - - // Use SpinWait instead of Sleep to demonstrate the - // effect of calling Interrupt on a running thread. - Thread::SpinWait( 10000000 ); - } - - try - { - Console::WriteLine( "newThread going to sleep." ); - - // When newThread goes to sleep, it is immediately - // woken up by a ThreadInterruptedException. - Thread::Sleep( Timeout::Infinite ); - } - catch ( ThreadInterruptedException^ /*e*/ ) - { - Console::WriteLine( "newThread cannot go to sleep - " - "interrupted by main thread." ); - } - - } - -}; - -int main() -{ - StayAwake^ stayAwake = gcnew StayAwake; - Thread^ newThread = gcnew Thread( gcnew ThreadStart( stayAwake, &StayAwake::ThreadMethod ) ); - newThread->Start(); - - // The following line causes an exception to be thrown - // in ThreadMethod if newThread is currently blocked - // or becomes blocked in the future. - newThread->Interrupt(); - Console::WriteLine( "Main thread calls Interrupt on newThread." ); - - // Then tell newThread to go to sleep. - stayAwake->SleepSwitch = true; - - // Wait for newThread to end. - newThread->Join(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsBackground/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsBackground/CPP/source.cpp deleted file mode 100644 index 7743178ff7e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsBackground/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -ref class BackgroundTest -{ -private: - int maxIterations; - -public: - BackgroundTest(int maxIterations) - { - this->maxIterations = maxIterations; - } - - void RunLoop() - { - for (int i = 0; i < maxIterations; i++ ) - { - Console::WriteLine("{0} count: {1}", - Thread::CurrentThread->IsBackground ? - "Background Thread" : "Foreground Thread", i); - Thread::Sleep(250); - - } - Console::WriteLine("{0} finished counting.", - Thread::CurrentThread->IsBackground ? - "Background Thread" : "Foreground Thread"); - } -}; - -int main() -{ - BackgroundTest^ shortTest = gcnew BackgroundTest( 10 ); - Thread^ foregroundThread = gcnew Thread( gcnew ThreadStart( shortTest, &BackgroundTest::RunLoop ) ); - foregroundThread->Name = "ForegroundThread"; - BackgroundTest^ longTest = gcnew BackgroundTest( 50 ); - Thread^ backgroundThread = gcnew Thread( gcnew ThreadStart( longTest, &BackgroundTest::RunLoop ) ); - backgroundThread->Name = "BackgroundThread"; - backgroundThread->IsBackground = true; - foregroundThread->Start(); - backgroundThread->Start(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsThreadPoolThread/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsThreadPoolThread/CPP/source.cpp deleted file mode 100644 index 9ae320e27d8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsThreadPoolThread/CPP/source.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class IsThreadPool -{ -public: - - // - static void ThreadMethod() - { - Console::WriteLine( "ThreadOne, executing ThreadMethod, " - "is {0}from the thread pool.", Thread::CurrentThread->IsThreadPoolThread ? (String^)"" : "not " ); - } - - - // - static void WorkMethod( Object^ stateInfo ) - { - Console::WriteLine( "ThreadTwo, executing WorkMethod, " - "is {0}from the thread pool.", Thread::CurrentThread->IsThreadPoolThread ? (String^)"" : "not " ); - - // Signal that this thread is finished. - dynamic_cast(stateInfo)->Set(); - } - -}; - -int main() -{ - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - Thread^ regularThread = gcnew Thread( gcnew ThreadStart( &IsThreadPool::ThreadMethod ) ); - regularThread->Start(); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &IsThreadPool::WorkMethod ), autoEvent ); - - // Wait for foreground thread to end. - regularThread->Join(); - - // Wait for background thread to end. - autoEvent->WaitOne(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp deleted file mode 100644 index 7ef570a3bad..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -ref class Slot -{ -private: - static Random^ randomGenerator = gcnew Random(); - -public: - static void SlotTest() - { - // Set random data in each thread's data slot. - int slotData = randomGenerator->Next(1, 200); - int threadId = Thread::CurrentThread->ManagedThreadId; - - Thread::SetData( - Thread::GetNamedDataSlot("Random"), - slotData); - - // Show what was saved in the thread's data slot. - Console::WriteLine("Data stored in thread_{0}'s data slot: {1,3}", - threadId, slotData); - - // Allow other threads time to execute SetData to show - // that a thread's data slot is unique to itself. - Thread::Sleep(1000); - - int newSlotData = - (int)Thread::GetData(Thread::GetNamedDataSlot("Random")); - - if (newSlotData == slotData) - { - Console::WriteLine("Data in thread_{0}'s data slot is still: {1,3}", - threadId, newSlotData); - } - else - { - Console::WriteLine("Data in thread_{0}'s data slot changed to: {1,3}", - threadId, newSlotData); - } - } -}; - -ref class Test -{ -public: - static void Main() - { - array^ newThreads = gcnew array(4); - int i; - for (i = 0; i < newThreads->Length; i++) - { - newThreads[i] = - gcnew Thread(gcnew ThreadStart(&Slot::SlotTest)); - newThreads[i]->Start(); - } - Thread::Sleep(2000); - for (i = 0; i < newThreads->Length; i++) - { - newThreads[i]->Join(); - Console::WriteLine("Thread_{0} finished.", - newThreads[i]->ManagedThreadId); - } - } -}; - -int main() -{ - Test::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Timespan/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Timespan/CPP/source.cpp deleted file mode 100644 index 3f8ee654cfc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Timespan/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -static TimeSpan waitTime = TimeSpan(0,0,1); - -ref class Test -{ -public: - static void Work() - { - Thread::Sleep( waitTime ); - } - -}; - -int main() -{ - Thread^ newThread = gcnew Thread( gcnew ThreadStart( Test::Work ) ); - newThread->Start(); - if ( newThread->Join( waitTime + waitTime ) ) - { - Console::WriteLine( "New thread terminated." ); - } - else - { - Console::WriteLine( "Join timed out." ); - } -} -// The example displays the following output: -// New thread terminated. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor/CPP/source.cpp deleted file mode 100644 index d4ca56d299c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Work -{ -private: - Work(){} - - -public: - static void DoWork(){} - -}; - -int main() -{ - Thread^ newThread = gcnew Thread( gcnew ThreadStart( &Work::DoWork ) ); - newThread->Start(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor2/CPP/source.cpp deleted file mode 100644 index 0ac57be1362..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor2/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Work -{ -public: - Work(){} - - void DoWork(){} - -}; - -int main() -{ - Work^ threadWork = gcnew Work; - Thread^ newThread = gcnew Thread( gcnew ThreadStart( threadWork, &Work::DoWork ) ); - newThread->Start(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/CPP/source.cpp deleted file mode 100644 index 2f2ccf1a8d9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -ref class Example -{ -public: - - // This thread procedure performs the task. - static void ThreadProc(Object^ stateInfo) - { - - // No state object was passed to QueueUserWorkItem, so stateInfo is 0. - Console::WriteLine( "Hello from the thread pool." ); - } -}; - -int main() -{ - // Queue the task. - ThreadPool::QueueUserWorkItem(gcnew WaitCallback(Example::ThreadProc)); - - Console::WriteLine("Main thread does some work, then sleeps."); - - Thread::Sleep(1000); - Console::WriteLine("Main thread exits."); - return 0; -} -// The example displays output like the following: -// Main thread does some work, then sleeps. -// Hello from the thread pool. -// Main thread exits. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem1/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem1/CPP/source.cpp deleted file mode 100644 index 94c24506593..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem1/CPP/source.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -public ref class Fibonacci -{ -private: - ManualResetEvent^ _doneEvent; - - int Calculate(int n) - { - if (n <= 1) - { - return n; - } - return Calculate(n - 1) + Calculate(n - 2); - } - -public: - - int ID; - int N; - int FibOfN; - - Fibonacci(int id, int n, ManualResetEvent^ doneEvent) - { - ID = id; - N = n; - _doneEvent = doneEvent; - } - - void Calculate() - { - FibOfN = Calculate(N); - } - - void SetDone() - { - _doneEvent->Set(); - } -}; - -public ref struct Example -{ -public: - - static void ThreadProc(Object^ stateInfo) - { - Fibonacci^ f = dynamic_cast(stateInfo); - Console::WriteLine("Thread {0} started...", f->ID); - f->Calculate(); - Console::WriteLine("Thread {0} result calculated...", f->ID); - f->SetDone(); - } -}; - - -void main() -{ - const int FibonacciCalculations = 5; - - array^ doneEvents = gcnew array(FibonacciCalculations); - array^ fibArray = gcnew array(FibonacciCalculations); - Random^ rand = gcnew Random(); - - Console::WriteLine("Launching {0} tasks...", FibonacciCalculations); - - for (int i = 0; i < FibonacciCalculations; i++) - { - doneEvents[i] = gcnew ManualResetEvent(false); - Fibonacci^ f = gcnew Fibonacci(i, rand->Next(20, 40), doneEvents[i]); - fibArray[i] = f; - ThreadPool::QueueUserWorkItem(gcnew WaitCallback(Example::ThreadProc), f); - } - - WaitHandle::WaitAll(doneEvents); - Console::WriteLine("All calculations are complete."); - - for (int i = 0; i < FibonacciCalculations; i++) - { - Fibonacci^ f = fibArray[i]; - Console::WriteLine("Fibonacci({0}) = {1}", f->N, f->FibOfN); - } -} -// Output is similar to: -// Launching 5 tasks... -// Thread 3 started... -// Thread 2 started... -// Thread 1 started... -// Thread 0 started... -// Thread 4 started... -// Thread 4 result calculated... -// Thread 1 result calculated... -// Thread 2 result calculated... -// Thread 0 result calculated... -// Thread 3 result calculated... -// All calculations are complete. -// Fibonacci(30) = 832040 -// Fibonacci(24) = 46368 -// Fibonacci(26) = 121393 -// Fibonacci(36) = 14930352 -// Fibonacci(20) = 6765 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp deleted file mode 100644 index 290d35f3698..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp +++ /dev/null @@ -1,86 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -// TaskInfo contains data that will be passed to the callback -// method. -public ref class TaskInfo -{ -public: - TaskInfo() - { - Handle = nullptr; - OtherInfo = "default"; - } - - RegisteredWaitHandle^ Handle; - String^ OtherInfo; -}; - -ref class Example -{ -public: - - // The callback method executes when the registered wait times out, - // or when the WaitHandle (in this case AutoResetEvent) is signaled. - // WaitProc unregisters the WaitHandle the first time the event is - // signaled. - static void WaitProc( Object^ state, bool timedOut ) - { - - // The state Object must be cast to the correct type, because the - // signature of the WaitOrTimerCallback delegate specifies type - // Object. - TaskInfo^ ti = static_cast(state); - String^ cause = "TIMED OUT"; - if ( !timedOut ) - { - cause = "SIGNALED"; - - // If the callback method executes because the WaitHandle is - // signaled, stop future execution of the callback method - // by unregistering the WaitHandle. - if ( ti->Handle != nullptr ) - ti->Handle->Unregister( nullptr ); - } - - Console::WriteLine( "WaitProc( {0}) executes on thread {1}; cause = {2}.", ti->OtherInfo, Thread::CurrentThread->GetHashCode(), cause ); - } - -}; - -int main() -{ - - // The main thread uses AutoResetEvent to signal the - // registered wait handle, which executes the callback - // method. - AutoResetEvent^ ev = gcnew AutoResetEvent( false ); - TaskInfo^ ti = gcnew TaskInfo; - ti->OtherInfo = "First task"; - - // The TaskInfo for the task includes the registered wait - // handle returned by RegisterWaitForSingleObject. This - // allows the wait to be terminated when the object has - // been signaled once (see WaitProc). - ti->Handle = ThreadPool::RegisterWaitForSingleObject( ev, gcnew WaitOrTimerCallback( Example::WaitProc ), ti, 1000, false ); - - // The main thread waits three seconds, to demonstrate the - // time-outs on the queued thread, and then signals. - Thread::Sleep( 3100 ); - Console::WriteLine( "Main thread signals." ); - ev->Set(); - - // The main thread sleeps, which should give the callback - // method time to execute. If you comment out this line, the - // program usually ends before the ThreadPool thread can execute. - Thread::Sleep( 1000 ); - - // If you start a thread yourself, you can wait for it to end - // by calling Thread::Join. This option is not available with - // thread pool threads. - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetAvailableThreads/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetAvailableThreads/CPP/source.cpp deleted file mode 100644 index 4d728332eac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetAvailableThreads/CPP/source.cpp +++ /dev/null @@ -1,114 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Permissions; -using namespace System::Threading; - -ref class ThreadPoolTest -{ -private: - - // Maintains state information to be passed to EndWriteCallback. - // This information allows the callback to end the asynchronous - // write operation and signal when it is finished. - ref class State - { - public: - FileStream^ fStream; - AutoResetEvent^ autoEvent; - State( FileStream^ fStream, AutoResetEvent^ autoEvent ) - { - this->fStream = fStream; - this->autoEvent = autoEvent; - } - - }; - - -public: - ThreadPoolTest(){} - - static void EndWriteCallback( IAsyncResult^ asyncResult ) - { - Console::WriteLine( "Starting EndWriteCallback." ); - State^ stateInfo = dynamic_cast(asyncResult->AsyncState); - int workerThreads; - int portThreads; - try - { - ThreadPool::GetAvailableThreads( workerThreads, portThreads ); - Console::WriteLine( "\nAvailable worker threads: \t{0}" - "\nAvailable completion port threads: {1}\n", workerThreads.ToString(), portThreads.ToString() ); - stateInfo->fStream->EndWrite( asyncResult ); - - // Sleep so the other thread has a chance to run - // before the current thread ends. - Thread::Sleep( 1500 ); - } - catch ( Exception^ e ) - { - } - finally - { - - // Signal that the current thread is finished. - stateInfo->autoEvent->Set(); - Console::WriteLine( "Ending EndWriteCallback." ); - } - - } - - static void WorkItemMethod( Object^ mainEvent ) - { - Console::WriteLine( "\nStarting WorkItem.\n" ); - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - - // Create some data. - const int ArraySize = 10000; - const int BufferSize = 1000; - array^byteArray = gcnew array(ArraySize); - (gcnew Random)->NextBytes( byteArray ); - - // Create two files and two State objects. - FileStream^ fileWriter1 = gcnew FileStream( "C:\\Test1@##.dat",FileMode::Create,FileAccess::ReadWrite,FileShare::ReadWrite,BufferSize,true ); - FileStream^ fileWriter2 = gcnew FileStream( "C:\\Test2@##.dat",FileMode::Create,FileAccess::ReadWrite,FileShare::ReadWrite,BufferSize,true ); - State^ stateInfo1 = gcnew State( fileWriter1,autoEvent ); - State^ stateInfo2 = gcnew State( fileWriter2,autoEvent ); - - // Asynchronously write to the files. - fileWriter1->BeginWrite( byteArray, 0, byteArray->Length, gcnew AsyncCallback( &ThreadPoolTest::EndWriteCallback ), stateInfo1 ); - fileWriter2->BeginWrite( byteArray, 0, byteArray->Length, gcnew AsyncCallback( &ThreadPoolTest::EndWriteCallback ), stateInfo2 ); - - // Wait for each callback to finish. - autoEvent->WaitOne(); - autoEvent->WaitOne(); - fileWriter1->Close(); - fileWriter2->Close(); - Console::WriteLine( "\nEnding WorkItem.\n" ); - - // Signal Main that the work item is finished. - dynamic_cast(mainEvent)->Set(); - } - -}; - -int main() -{ - AutoResetEvent^ mainEvent = gcnew AutoResetEvent( false ); - int workerThreads; - int portThreads; - ThreadPool::GetMaxThreads( workerThreads, portThreads ); - Console::WriteLine( "\nMaximum worker threads: \t{0}" - "\nMaximum completion port threads: {1}", workerThreads.ToString(), portThreads.ToString() ); - ThreadPool::GetAvailableThreads( workerThreads, portThreads ); - Console::WriteLine( "\nAvailable worker threads: \t{0}" - "\nAvailable completion port threads: {1}\n", workerThreads.ToString(), portThreads.ToString() ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &ThreadPoolTest::WorkItemMethod ), mainEvent ); - - // Since ThreadPool threads are background threads, - // wait for the work item to signal before ending main(). - mainEvent->WaitOne( 5000, false ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetSetMinThreads/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetSetMinThreads/CPP/source.cpp deleted file mode 100644 index 654530d80b8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetSetMinThreads/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -int main() -{ - int minWorker; - int minIOC; - - // Get the current settings. - ThreadPool::GetMinThreads( minWorker, minIOC ); - - // Change the minimum number of worker threads to four, but - // keep the old setting for minimum asynchronous I/O - // completion threads. - if ( ThreadPool::SetMinThreads( 4, minIOC ) ) - { - - // The minimum number of threads was set successfully. - } - else - { - - // The minimum number of threads was not changed. - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadStart2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadStart2/CPP/source.cpp deleted file mode 100644 index 3295346dbdc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadStart2/CPP/source.cpp +++ /dev/null @@ -1,49 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Work -{ -public: - static void DoWork() - { - Console::WriteLine( "Static thread procedure." ); - } - - int Data; - void DoMoreWork() - { - Console::WriteLine( "Instance thread procedure. Data={0}", Data ); - } - -}; - -int main() -{ - - // To start a thread using an instance method for the thread - // procedure, specify the object as the first argument of the - // ThreadStart constructor. - // - Work^ w = gcnew Work; - w->Data = 42; - ThreadStart^ threadDelegate = gcnew ThreadStart( w, &Work::DoMoreWork ); - Thread^ newThread = gcnew Thread( threadDelegate ); - newThread->Start(); - - // To start a thread using a static thread procedure, specify - // only the address of the procedure. This is a change from - // earlier versions of the .NET Framework, which required - // two arguments, the first of which was null (0). - // - threadDelegate = gcnew ThreadStart( &Work::DoWork ); - newThread = gcnew Thread( threadDelegate ); - newThread->Start(); -} - -/* This code example produces the following output (the order - of the lines might vary): -Static thread procedure. -Instance thread procedure. Data=42 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp deleted file mode 100644 index 4dd79b85f2c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -ref class StatusChecker -{ -private: - int invokeCount, maxCount; - -public: - StatusChecker(int count) - { - invokeCount = 0; - maxCount = count; - } - - // This method is called by the timer delegate. - void CheckStatus(Object^ stateInfo) - { - AutoResetEvent^ autoEvent = dynamic_cast(stateInfo); - Console::WriteLine("{0:h:mm:ss.fff} Checking status {1,2}.", - DateTime::Now, ++invokeCount); - - if (invokeCount == maxCount) { - // Reset the counter and signal the waiting thread. - invokeCount = 0; - autoEvent->Set(); - } - } -}; - -ref class TimerExample -{ -public: - static void Main() - { - // Create an AutoResetEvent to signal the timeout threshold in the - // timer callback has been reached. - AutoResetEvent^ autoEvent = gcnew AutoResetEvent(false); - - StatusChecker^ statusChecker = gcnew StatusChecker(10); - - // Create a delegate that invokes methods for the timer. - TimerCallback^ tcb = - gcnew TimerCallback(statusChecker, &StatusChecker::CheckStatus); - - // Create a timer that invokes CheckStatus after one second, - // and every 1/4 second thereafter. - Console::WriteLine("{0:h:mm:ss.fff} Creating timer.\n", - DateTime::Now); - Timer^ stateTimer = gcnew Timer(tcb, autoEvent, 1000, 250); - - // When autoEvent signals, change the period to every half second. - autoEvent->WaitOne(5000, false); - stateTimer->Change(0, 500); - Console::WriteLine("\nChanging period to .5 seconds.\n"); - - // When autoEvent signals the second time, dispose of the timer. - autoEvent->WaitOne(5000, false); - stateTimer->~Timer(); - Console::WriteLine("\nDestroying timer."); - } -}; - -int main() -{ - TimerExample::Main(); -} -// The example displays output like the following: -// 11:59:54.202 Creating timer. -// -// 11:59:55.217 Checking status 1. -// 11:59:55.466 Checking status 2. -// 11:59:55.716 Checking status 3. -// 11:59:55.968 Checking status 4. -// 11:59:56.218 Checking status 5. -// 11:59:56.470 Checking status 6. -// 11:59:56.722 Checking status 7. -// 11:59:56.972 Checking status 8. -// 11:59:57.223 Checking status 9. -// 11:59:57.473 Checking status 10. -// -// Changing period to .5 seconds. -// -// 11:59:57.474 Checking status 1. -// 11:59:57.976 Checking status 2. -// 11:59:58.476 Checking status 3. -// 11:59:58.977 Checking status 4. -// 11:59:59.477 Checking status 5. -// 11:59:59.977 Checking status 6. -// 12:00:00.478 Checking status 7. -// 12:00:00.980 Checking status 8. -// 12:00:01.481 Checking status 9. -// 12:00:01.981 Checking status 10. -// -// Destroying timer. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer2/CPP/source2.cpp deleted file mode 100644 index ec633fe45b1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer2/CPP/source2.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class StatusChecker -{ -private: - int invokeCount; - int maxCount; - -public: - StatusChecker( int count ) - : invokeCount( 0 ), maxCount( count ) - {} - - - // This method is called by the timer delegate. - void CheckStatus( Object^ stateInfo ) - { - AutoResetEvent^ autoEvent = dynamic_cast(stateInfo); - Console::WriteLine( "{0} Checking status {1,2}.", DateTime::Now.ToString( "h:mm:ss.fff" ), (++invokeCount).ToString() ); - if ( invokeCount == maxCount ) - { - - // Reset the counter and signal main. - invokeCount = 0; - autoEvent->Set(); - } - } - -}; - -int main() -{ - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - StatusChecker^ statusChecker = gcnew StatusChecker( 10 ); - - // Create the delegate that invokes methods for the timer. - TimerCallback^ timerDelegate = gcnew TimerCallback( statusChecker, &StatusChecker::CheckStatus ); - TimeSpan delayTime = TimeSpan(0,0,1); - TimeSpan intervalTime = TimeSpan(0,0,0,0,250); - - // Create a timer that signals the delegate to invoke CheckStatus - // after one second, and every 1/4 second thereafter. - Console::WriteLine( "{0} Creating timer.\n", DateTime::Now.ToString( "h:mm:ss.fff" ) ); - Timer^ stateTimer = gcnew Timer( timerDelegate,autoEvent,delayTime,intervalTime ); - - // When autoEvent signals, change the period to every 1/2 second. - autoEvent->WaitOne( 5000, false ); - stateTimer->Change( TimeSpan(0), intervalTime + intervalTime ); - Console::WriteLine( "\nChanging period.\n" ); - - // When autoEvent signals the second time, dispose of the timer. - autoEvent->WaitOne( 5000, false ); - stateTimer->~Timer(); - Console::WriteLine( "\nDestroying timer." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp deleted file mode 100644 index 2de583f098d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -public ref class Example -{ -private: - // The EventWaitHandle used to demonstrate the difference - // between AutoReset and ManualReset synchronization events. - // - static EventWaitHandle^ ewh; - - // A counter to make sure all threads are started and - // blocked before any are released. A Long is used to show - // the use of the 64-bit Interlocked methods. - // - static __int64 threadCount = 0; - - // An AutoReset event that allows the main thread to block - // until an exiting thread has decremented the count. - // - static EventWaitHandle^ clearCount = - gcnew EventWaitHandle( false,EventResetMode::AutoReset ); - -public: - [MTAThread] - static void main() - { - // Create an AutoReset EventWaitHandle. - // - ewh = gcnew EventWaitHandle( false,EventResetMode::AutoReset ); - - // Create and start five numbered threads. Use the - // ParameterizedThreadStart delegate, so the thread - // number can be passed as an argument to the Start - // method. - for ( int i = 0; i <= 4; i++ ) - { - Thread^ t = gcnew Thread( - gcnew ParameterizedThreadStart( ThreadProc ) ); - t->Start( i ); - } - - // Wait until all the threads have started and blocked. - // When multiple threads use a 64-bit value on a 32-bit - // system, you must access the value through the - // Interlocked class to guarantee thread safety. - // - while ( Interlocked::Read( threadCount ) < 5 ) - { - Thread::Sleep( 500 ); - } - - // Release one thread each time the user presses ENTER, - // until all threads have been released. - // - while ( Interlocked::Read( threadCount ) > 0 ) - { - Console::WriteLine( L"Press ENTER to release a waiting thread." ); - Console::ReadLine(); - - // SignalAndWait signals the EventWaitHandle, which - // releases exactly one thread before resetting, - // because it was created with AutoReset mode. - // SignalAndWait then blocks on clearCount, to - // allow the signaled thread to decrement the count - // before looping again. - // - WaitHandle::SignalAndWait( ewh, clearCount ); - } - Console::WriteLine(); - - // Create a ManualReset EventWaitHandle. - // - ewh = gcnew EventWaitHandle( false,EventResetMode::ManualReset ); - - // Create and start five more numbered threads. - // - for ( int i = 0; i <= 4; i++ ) - { - Thread^ t = gcnew Thread( - gcnew ParameterizedThreadStart( ThreadProc ) ); - t->Start( i ); - } - - // Wait until all the threads have started and blocked. - // - while ( Interlocked::Read( threadCount ) < 5 ) - { - Thread::Sleep( 500 ); - } - - // Because the EventWaitHandle was created with - // ManualReset mode, signaling it releases all the - // waiting threads. - // - Console::WriteLine( L"Press ENTER to release the waiting threads." ); - Console::ReadLine(); - ewh->Set(); - - } - - static void ThreadProc( Object^ data ) - { - int index = static_cast(data); - - Console::WriteLine( L"Thread {0} blocks.", data ); - // Increment the count of blocked threads. - Interlocked::Increment( threadCount ); - - // Wait on the EventWaitHandle. - ewh->WaitOne(); - - Console::WriteLine( L"Thread {0} exits.", data ); - // Decrement the count of blocked threads. - Interlocked::Decrement( threadCount ); - - // After signaling ewh, the main thread blocks on - // clearCount until the signaled thread has - // decremented the count. Signal it now. - // - clearCount->Set(); - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll1/CPP/source1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll1/CPP/source1.cpp deleted file mode 100644 index 77becf280e4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll1/CPP/source1.cpp +++ /dev/null @@ -1,93 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Permissions; -using namespace System::Threading; - -ref class State -{ -public: - String^ fileName; - array^byteArray; - ManualResetEvent^ manualEvent; - State( String^ fileName, array^byteArray, ManualResetEvent^ manualEvent ) - : fileName( fileName ), byteArray( byteArray ), manualEvent( manualEvent ) - {} - -}; - -ref class Writer -{ -private: - static int workItemCount = 0; - Writer(){} - - -public: - static void WriteToFile( Object^ state ) - { - int workItemNumber = workItemCount; - Interlocked::Increment( workItemCount ); - Console::WriteLine( "Starting work item {0}.", workItemNumber.ToString() ); - State^ stateInfo = dynamic_cast(state); - FileStream^ fileWriter; - - // Create and write to the file. - try - { - fileWriter = gcnew FileStream( stateInfo->fileName,FileMode::Create ); - fileWriter->Write( stateInfo->byteArray, 0, stateInfo->byteArray->Length ); - } - finally - { - if ( fileWriter != nullptr ) - { - fileWriter->Close(); - } - - // Signal main() that the work item has finished. - Console::WriteLine( "Ending work item {0}.", workItemNumber.ToString() ); - stateInfo->manualEvent->Set(); - } - - } - -}; - -void main() -{ - const int numberOfFiles = 5; - String^ dirName = "C:\\TestTest"; - String^ fileName; - array^byteArray; - Random^ randomGenerator = gcnew Random; - array^manualEvents = gcnew array(numberOfFiles); - State^ stateInfo; - if ( !Directory::Exists( dirName ) ) - { - Directory::CreateDirectory( dirName ); - } - - - // Queue the work items that create and write to the files. - for ( int i = 0; i < numberOfFiles; i++ ) - { - fileName = String::Concat( dirName, "\\Test", ((i)).ToString(), ".dat" ); - - // Create random data to write to the file. - byteArray = gcnew array(1000000); - randomGenerator->NextBytes( byteArray ); - manualEvents[ i ] = gcnew ManualResetEvent( false ); - stateInfo = gcnew State( fileName,byteArray,manualEvents[ i ] ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &Writer::WriteToFile ), stateInfo ); - - } - - // Since ThreadPool threads are background threads, - // wait for the work items to signal before exiting. - WaitHandle::WaitAll( manualEvents ); - Console::WriteLine( "Files written - main exiting." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll2/CPP/source2.cpp deleted file mode 100644 index 8cad6cf4acd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll2/CPP/source2.cpp +++ /dev/null @@ -1,102 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Permissions; -using namespace System::Threading; - -// Maintain state to pass to WriteToFile. -ref class State -{ -public: - String^ fileName; - array^byteArray; - ManualResetEvent^ manualEvent; - State( String^ fileName, array^byteArray, ManualResetEvent^ manualEvent ) - : fileName( fileName ), byteArray( byteArray ), manualEvent( manualEvent ) - {} - -}; - -ref class Writer -{ -private: - static int workItemCount = 0; - Writer(){} - - -public: - static void WriteToFile( Object^ state ) - { - int workItemNumber = workItemCount; - Interlocked::Increment( workItemCount ); - Console::WriteLine( "Starting work item {0}.", workItemNumber.ToString() ); - State^ stateInfo = dynamic_cast(state); - FileStream^ fileWriter; - - // Create and write to the file. - try - { - fileWriter = gcnew FileStream( stateInfo->fileName,FileMode::Create ); - fileWriter->Write( stateInfo->byteArray, 0, stateInfo->byteArray->Length ); - } - finally - { - if ( fileWriter != nullptr ) - { - fileWriter->Close(); - } - - // Signal main() that the work item has finished. - Console::WriteLine( "Ending work item {0}.", workItemNumber.ToString() ); - stateInfo->manualEvent->Set(); - } - - } - -}; - -int main() -{ - const int numberOfFiles = 5; - String^ dirName = "C:\\TestTest"; - String^ fileName; - array^byteArray; - Random^ randomGenerator = gcnew Random; - array^manualEvents = gcnew array(numberOfFiles); - State^ stateInfo; - if ( !Directory::Exists( dirName ) ) - { - Directory::CreateDirectory( dirName ); - } - - - // Queue the work items that create and write to the files. - for ( int i = 0; i < numberOfFiles; i++ ) - { - fileName = String::Concat( dirName, "\\Test", ((i)).ToString(), ".dat" ); - - // Create random data to write to the file. - byteArray = gcnew array(1000000); - randomGenerator->NextBytes( byteArray ); - manualEvents[ i ] = gcnew ManualResetEvent( false ); - stateInfo = gcnew State( fileName,byteArray,manualEvents[ i ] ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &Writer::WriteToFile ), stateInfo ); - - } - - // Since ThreadPool threads are background threads, - // wait for the work items to signal before exiting. - if ( WaitHandle::WaitAll( manualEvents, 5000, false ) ) - { - Console::WriteLine( "Files written - main exiting." ); - } - else - { - - // The wait operation times out. - Console::WriteLine( "Error writing files - main exiting." ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll3/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll3/CPP/source3.cpp deleted file mode 100644 index 6044e88bdcc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll3/CPP/source3.cpp +++ /dev/null @@ -1,102 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Permissions; -using namespace System::Threading; - -// Maintain state to pass to WriteToFile. -ref class State -{ -public: - String^ fileName; - array^byteArray; - ManualResetEvent^ manualEvent; - State( String^ fileName, array^byteArray, ManualResetEvent^ manualEvent ) - : fileName( fileName ), byteArray( byteArray ), manualEvent( manualEvent ) - {} - -}; - -ref class Writer -{ -private: - static int workItemCount = 0; - Writer(){} - - -public: - static void WriteToFile( Object^ state ) - { - int workItemNumber = workItemCount; - Interlocked::Increment( workItemCount ); - Console::WriteLine( "Starting work item {0}.", workItemNumber.ToString() ); - State^ stateInfo = dynamic_cast(state); - FileStream^ fileWriter; - - // Create and write to the file. - try - { - fileWriter = gcnew FileStream( stateInfo->fileName,FileMode::Create ); - fileWriter->Write( stateInfo->byteArray, 0, stateInfo->byteArray->Length ); - } - finally - { - if ( fileWriter != nullptr ) - { - fileWriter->Close(); - } - - // Signal main() that the work item has finished. - Console::WriteLine( "Ending work item {0}.", workItemNumber.ToString() ); - stateInfo->manualEvent->Set(); - } - - } - -}; - -int main() -{ - const int numberOfFiles = 5; - String^ dirName = "C:\\TestTest"; - String^ fileName; - array^byteArray; - Random^ randomGenerator = gcnew Random; - array^manualEvents = gcnew array(numberOfFiles); - State^ stateInfo; - if ( !Directory::Exists( dirName ) ) - { - Directory::CreateDirectory( dirName ); - } - - - // Queue the work items that create and write to the files. - for ( int i = 0; i < numberOfFiles; i++ ) - { - fileName = String::Concat( dirName, "\\Test", ((i)).ToString(), ".dat" ); - - // Create random data to write to the file. - byteArray = gcnew array(1000000); - randomGenerator->NextBytes( byteArray ); - manualEvents[ i ] = gcnew ManualResetEvent( false ); - stateInfo = gcnew State( fileName,byteArray,manualEvents[ i ] ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &Writer::WriteToFile ), stateInfo ); - - } - - // Since ThreadPool threads are background threads, - // wait for the work items to signal before exiting. - if ( WaitHandle::WaitAll( manualEvents, TimeSpan(0,0,5), false ) ) - { - Console::WriteLine( "Files written - main exiting." ); - } - else - { - - // The wait operation times out. - Console::WriteLine( "Error writing files - main exiting." ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny2/CPP/source2.cpp deleted file mode 100644 index 5873df3b3ad..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny2/CPP/source2.cpp +++ /dev/null @@ -1,83 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Threading; -ref class Search -{ -private: - - // Maintain state information to pass to FindCallback. - ref class State - { - public: - AutoResetEvent^ autoEvent; - String^ fileName; - State( AutoResetEvent^ autoEvent, String^ fileName ) - : autoEvent( autoEvent ), fileName( fileName ) - {} - - }; - - -public: - array^autoEvents; - array^diskLetters; - - // Search for stateInfo->fileName. - void FindCallback( Object^ state ) - { - State^ stateInfo = dynamic_cast(state); - - // Signal if the file is found. - if ( File::Exists( stateInfo->fileName ) ) - { - stateInfo->autoEvent->Set(); - } - } - - Search() - { - - // Retrieve an array of disk letters. - diskLetters = Environment::GetLogicalDrives(); - autoEvents = gcnew array(diskLetters->Length); - for ( int i = 0; i < diskLetters->Length; i++ ) - { - autoEvents[ i ] = gcnew AutoResetEvent( false ); - - } - } - - - // Search for fileName in the root directory of all disks. - void FindFile( String^ fileName ) - { - for ( int i = 0; i < diskLetters->Length; i++ ) - { - Console::WriteLine( "Searching for {0} on {1}.", fileName, diskLetters[ i ] ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( this, &Search::FindCallback ), gcnew State( autoEvents[ i ],String::Concat( diskLetters[ i ], fileName ) ) ); - - } - - // Wait for the first instance of the file to be found. - int index = WaitHandle::WaitAny( autoEvents, 3000, false ); - if ( index == WaitHandle::WaitTimeout ) - { - Console::WriteLine( "\n{0} not found.", fileName ); - } - else - { - Console::WriteLine( "\n{0} found on {1}.", fileName, diskLetters[ index ] ); - } - } - -}; - -int main() -{ - Search^ search = gcnew Search; - search->FindFile( "SomeFile.dat" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny3/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny3/CPP/source3.cpp deleted file mode 100644 index c8fbef542b7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny3/CPP/source3.cpp +++ /dev/null @@ -1,83 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Threading; -ref class Search -{ -private: - - // Maintain state information to pass to FindCallback. - ref class State - { - public: - AutoResetEvent^ autoEvent; - String^ fileName; - State( AutoResetEvent^ autoEvent, String^ fileName ) - : autoEvent( autoEvent ), fileName( fileName ) - {} - - }; - - -public: - array^autoEvents; - array^diskLetters; - - // Search for stateInfo->fileName. - void FindCallback( Object^ state ) - { - State^ stateInfo = dynamic_cast(state); - - // Signal if the file is found. - if ( File::Exists( stateInfo->fileName ) ) - { - stateInfo->autoEvent->Set(); - } - } - - Search() - { - - // Retrieve an array of disk letters. - diskLetters = Environment::GetLogicalDrives(); - autoEvents = gcnew array(diskLetters->Length); - for ( int i = 0; i < diskLetters->Length; i++ ) - { - autoEvents[ i ] = gcnew AutoResetEvent( false ); - - } - } - - - // Search for fileName in the root directory of all disks. - void FindFile( String^ fileName ) - { - for ( int i = 0; i < diskLetters->Length; i++ ) - { - Console::WriteLine( "Searching for {0} on {1}.", fileName, diskLetters[ i ] ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( this, &Search::FindCallback ), gcnew State( autoEvents[ i ],String::Concat( diskLetters[ i ], fileName ) ) ); - - } - - // Wait for the first instance of the file to be found. - int index = WaitHandle::WaitAny( autoEvents, TimeSpan(0,0,3), false ); - if ( index == WaitHandle::WaitTimeout ) - { - Console::WriteLine( "\n{0} not found.", fileName ); - } - else - { - Console::WriteLine( "\n{0} found on {1}.", fileName, diskLetters[ index ] ); - } - } - -}; - -int main() -{ - Search^ search = gcnew Search; - search->FindFile( "SomeFile.dat" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne1/CPP/source1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne1/CPP/source1.cpp deleted file mode 100644 index 1e895c2aace..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne1/CPP/source1.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class WaitOne -{ -private: - WaitOne(){} - - -public: - static void WorkMethod( Object^ stateInfo ) - { - Console::WriteLine( "Work starting." ); - - // Simulate time spent working. - Thread::Sleep( (gcnew Random)->Next( 100, 2000 ) ); - - // Signal that work is finished. - Console::WriteLine( "Work ending." ); - dynamic_cast(stateInfo)->Set(); - } - -}; - -int main() -{ - Console::WriteLine( "Main starting." ); - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &WaitOne::WorkMethod ), autoEvent ); - - // Wait for work method to signal. - autoEvent->WaitOne( ); - Console::WriteLine( "Work method signaled.\nMain ending." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne2/CPP/source2.cpp deleted file mode 100644 index 2d2d9d3a98f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne2/CPP/source2.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class WaitOne -{ -private: - WaitOne(){} - - -public: - static void WorkMethod( Object^ stateInfo ) - { - Console::WriteLine( "Work starting." ); - - // Simulate time spent working. - Thread::Sleep( (gcnew Random)->Next( 100, 2000 ) ); - - // Signal that work is finished. - Console::WriteLine( "Work ending." ); - dynamic_cast(stateInfo)->Set(); - } - -}; - -int main() -{ - Console::WriteLine( "Main starting." ); - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &WaitOne::WorkMethod ), autoEvent ); - - // Wait for work method to signal. - if ( autoEvent->WaitOne( 1000 ) ) - { - Console::WriteLine( "Work method signaled." ); - } - else - { - Console::WriteLine( "Timed out waiting for work " - "method to signal." ); - } - - Console::WriteLine( "Main ending." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne3/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne3/CPP/source3.cpp deleted file mode 100644 index d43bd113677..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne3/CPP/source3.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class WaitOne -{ -private: - WaitOne(){} - - -public: - static void WorkMethod( Object^ stateInfo ) - { - Console::WriteLine( "Work starting." ); - - // Simulate time spent working. - Thread::Sleep( (gcnew Random)->Next( 100, 2000 ) ); - - // Signal that work is finished. - Console::WriteLine( "Work ending." ); - dynamic_cast(stateInfo)->Set(); - } - -}; - -int main() -{ - Console::WriteLine( "Main starting." ); - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &WaitOne::WorkMethod ), autoEvent ); - - // Wait for work method to signal. - if ( autoEvent->WaitOne( TimeSpan(0,0,1), false ) ) - { - Console::WriteLine( "Work method signaled." ); - } - else - { - Console::WriteLine( "Timed out waiting for work " - "method to signal." ); - } - - Console::WriteLine( "Main ending." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.text.regularexpressions.MatchEvaluator/CPP/regexreplace.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.text.regularexpressions.MatchEvaluator/CPP/regexreplace.cpp deleted file mode 100644 index e378abfd947..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.text.regularexpressions.MatchEvaluator/CPP/regexreplace.cpp +++ /dev/null @@ -1,49 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Text::RegularExpressions; -ref class MyClass -{ -public: - static int i = 0; - static String^ ReplaceCC( Match^ m ) - { - - // Replace each Regex cc match with the number of the occurrence. - i++; - return i.ToString(); - } - -}; - -int main() -{ - String^ sInput; - String^ sRegex; - - // The string to search. - sInput = "aabbccddeeffcccgghhcccciijjcccckkcc"; - - // A very simple regular expression. - sRegex = "cc"; - Regex^ r = gcnew Regex( sRegex ); - - // Assign the replace method to the MatchEvaluator delegate. - MatchEvaluator^ myEvaluator = gcnew MatchEvaluator( &MyClass::ReplaceCC ); - - // Write out the original string. - Console::WriteLine( sInput ); - - // Replace matched characters using the delegate method. - sInput = r->Replace( sInput, myEvaluator ); - - // Write out the modified string. - Console::WriteLine( sInput ); -} -// The example displays the following output: -// aabbccddeeffcccgghhcccciijjcccckkcc -// aabb11ddeeff22cgghh3344iijj5566kk77 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.threading.thread.threadstate/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.threading.thread.threadstate/cpp/source.cpp deleted file mode 100644 index 8cee8672a42..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.threading.thread.threadstate/cpp/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -// ref class ApartmentTest -// { -// public: - static void ThreadMethod() - { - Thread::Sleep( 1000 ); -// } - -}; - -int main() -{ -// Thread^ newThread = gcnew Thread( gcnew ThreadStart( &ApartmentTest::ThreadMethod ) ); - Thread^ newThread = gcnew Thread( gcnew ThreadStart( &ThreadMethod ) ); - - Console::WriteLine("ThreadState: {0}", newThread->ThreadState); - newThread->Start(); - - // Wait for newThread to start and go to sleep. - Thread::Sleep(300); - Console::WriteLine("ThreadState: {0}", newThread->ThreadState); - - // Wait for newThread to restart. - Thread::Sleep(1000); - Console::WriteLine("ThreadState: {0}", newThread->ThreadState); -} -// The example displays the following output: -// ThreadState: Unstarted -// ThreadState: WaitSleepJoin -// ThreadState: Stopped -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.threading.waithandle.waitone4/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.threading.waithandle.waitone4/cpp/source.cpp deleted file mode 100644 index 857931694b0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.threading.waithandle.waitone4/cpp/source.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// -using namespace System; -using namespace System::Threading; -using namespace System::Runtime::Remoting::Contexts; - -[Synchronization(true)] -public ref class SyncingClass : ContextBoundObject -{ -private: - EventWaitHandle^ waitHandle; - -public: - SyncingClass() - { - waitHandle = - gcnew EventWaitHandle(false, EventResetMode::ManualReset); - } - - void Signal() - { - Console::WriteLine("Thread[{0:d4}]: Signalling...", Thread::CurrentThread->GetHashCode()); - waitHandle->Set(); - } - - void DoWait(bool leaveContext) - { - bool signalled; - - waitHandle->Reset(); - Console::WriteLine("Thread[{0:d4}]: Waiting...", Thread::CurrentThread->GetHashCode()); - signalled = waitHandle->WaitOne(3000, leaveContext); - if (signalled) - { - Console::WriteLine("Thread[{0:d4}]: Wait released!!!", Thread::CurrentThread->GetHashCode()); - } - else - { - Console::WriteLine("Thread[{0:d4}]: Wait timeout!!!", Thread::CurrentThread->GetHashCode()); - } - } -}; - -public ref class TestSyncDomainWait -{ -public: - static void Main() - { - SyncingClass^ syncClass = gcnew SyncingClass(); - - Thread^ runWaiter; - - Console::WriteLine("\nWait and signal INSIDE synchronization domain:\n"); - runWaiter = gcnew Thread(gcnew ParameterizedThreadStart(&TestSyncDomainWait::RunWaitKeepContext)); - runWaiter->Start(syncClass); - Thread::Sleep(1000); - Console::WriteLine("Thread[{0:d4}]: Signal...", Thread::CurrentThread->GetHashCode()); - // This call to Signal will block until the timeout in DoWait expires. - syncClass->Signal(); - runWaiter->Join(); - - Console::WriteLine("\nWait and signal OUTSIDE synchronization domain:\n"); - runWaiter = gcnew Thread(gcnew ParameterizedThreadStart(&TestSyncDomainWait::RunWaitLeaveContext)); - runWaiter->Start(syncClass); - Thread::Sleep(1000); - Console::WriteLine("Thread[{0:d4}]: Signal...", Thread::CurrentThread->GetHashCode()); - // This call to Signal is unblocked and will set the wait handle to - // release the waiting thread. - syncClass->Signal(); - runWaiter->Join(); - } - - static void RunWaitKeepContext(Object^ parm) - { - ((SyncingClass^)parm)->DoWait(false); - } - - static void RunWaitLeaveContext(Object^ parm) - { - ((SyncingClass^)parm)->DoWait(true); - } -}; - -int main() -{ - TestSyncDomainWait::Main(); -} -// The output for the example program will be similar to the following: -// -// Wait and signal INSIDE synchronization domain: -// -// Thread[0004]: Waiting... -// Thread[0001]: Signal... -// Thread[0004]: Wait timeout!!! -// Thread[0001]: Signalling... -// -// Wait and signal OUTSIDE synchronization domain: -// -// Thread[0006]: Waiting... -// Thread[0001]: Signal... -// Thread[0001]: Signalling... -// Thread[0006]: Wait released!!! -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp deleted file mode 100644 index 84663c2d1bc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -using namespace System; -using namespace System::Timers; - -public ref class Example -{ -private: - static System::Timers::Timer^ aTimer; - -public: - static void Demo() - { - // Create a timer and set a two second interval. - aTimer = gcnew System::Timers::Timer(); - aTimer->Interval = 2000; - - // Hook up the Elapsed event for the timer. - aTimer->Elapsed += gcnew System::Timers::ElapsedEventHandler(Example::OnTimedEvent); - - // Have the timer fire repeated events (true is the default) - aTimer->AutoReset = true; - - // Start the timer - aTimer->Enabled = true; - - Console::WriteLine("Press the Enter key to exit the program at any time... "); - Console::ReadLine(); - } - -private: - static void OnTimedEvent(Object^ source, System::Timers::ElapsedEventArgs^ e) - { - Console::WriteLine("The Elapsed event was raised at {0}", e->SignalTime); - } -}; - -int main() -{ - Example::Demo(); -} -// The example displays output like the following: -// Press the Enter key to exit the program at any time... -// The Elapsed event was raised at 5/20/2015 8:48:58 PM -// The Elapsed event was raised at 5/20/2015 8:49:00 PM -// The Elapsed event was raised at 5/20/2015 8:49:02 PM -// The Elapsed event was raised at 5/20/2015 8:49:04 PM -// The Elapsed event was raised at 5/20/2015 8:49:06 PM - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/CPP/source.cpp deleted file mode 100644 index 248a1274b23..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "http://localhost/baseuri.xml" ); - - //Display information on the attribute node. The value - //returned for BaseURI is 'http://localhost/baseuri.xml'. - XmlAttribute^ attr = doc->DocumentElement->Attributes[ 0 ]; - Console::WriteLine( "Name of the attribute: {0}", attr->Name ); - Console::WriteLine( "Base URI of the attribute: {0}", attr->BaseURI ); - Console::WriteLine( "The value of the attribute: {0}", attr->InnerText ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/CPP/source.cpp deleted file mode 100644 index 7da06cb2507..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create an XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "2elems.xml" ); - - //Create an attribute. - XmlAttribute^ attr; - attr = doc->CreateAttribute( "bk", "genre", "urn:samples" ); - attr->Value = "novel"; - - //Add the attribute to the first book. - XmlElement^ currNode = dynamic_cast(doc->DocumentElement->FirstChild); - currNode->SetAttributeNode( attr ); - - //An attribute cannot be added to two different elements. - //You must clone the attribute and add it to the second book. - XmlAttribute^ attr2; - attr2 = dynamic_cast(attr->CloneNode( true )); - currNode = dynamic_cast(doc->DocumentElement->LastChild); - currNode->SetAttributeNode( attr2 ); - Console::WriteLine( "Display the modified XML...\r\n" ); - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - doc->WriteContentTo( writer ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.Name Example/CPP/source.cpp deleted file mode 100644 index e610435a6f1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.Name Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - Console::WriteLine( "Display information on each of the attributes... \r\n" ); - System::Collections::IEnumerator^ myEnum = attrColl->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlAttribute^ attr = safe_cast(myEnum->Current); - Console::Write( "{0} = {1}", attr->Name, attr->Value ); - Console::WriteLine( "\t namespaceURI={0}", attr->NamespaceURI ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/CPP/source.cpp deleted file mode 100644 index d5ae5b95da8..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - Console::WriteLine( "Display information on each of the attributes... \r\n" ); - System::Collections::IEnumerator^ myEnum = attrColl->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlAttribute^ attr = safe_cast(myEnum->Current); - Console::Write( "{0}:{1} = {2}", attr->Prefix, attr->LocalName, attr->Value ); - Console::WriteLine( "\t namespaceURI={0}", attr->NamespaceURI ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerDocument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerDocument Example/CPP/source.cpp deleted file mode 100644 index ab859d7c703..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerDocument Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute. - XmlAttribute^ attr; - attr = doc->CreateAttribute( "bk", "genre", "urn:samples" ); - attr->Value = "novel"; - - //Display the attribute's owner document. Note - //that although the attribute has not been inserted - //into the document, it still has an owner document. - Console::WriteLine( attr->OwnerDocument->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerElement Example/CPP/source.cpp deleted file mode 100644 index dcbf0298041..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerElement Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute. - XmlAttribute^ attr; - attr = doc->CreateAttribute( "bk", "genre", "urn:samples" ); - attr->Value = "novel"; - - //Try to display the attribute's owner element. - if ( attr->OwnerElement == nullptr ) - Console::WriteLine( "The attribute has not been added to an element\r\n" ); - else - Console::WriteLine( attr->OwnerElement->OuterXml ); - - - //Add the attribute to an element. - doc->DocumentElement->SetAttributeNode( attr ); - - //Display the attribute's owner element. - Console::WriteLine( "Display the owner element..." ); - Console::WriteLine( attr->OwnerElement->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Append Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Append Example/CPP/source.cpp deleted file mode 100644 index 3adf20c7f03..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Append Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create a new attribute. - XmlAttribute^ newAttr = doc->CreateAttribute( "genre" ); - newAttr->Value = "novel"; - - //Create an attribute collection and add the new attribute - //to the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->Append( newAttr ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.CopyTo Example/CPP/source.cpp deleted file mode 100644 index ac6d9660ec5..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - - //Declare the array. - array^arr = gcnew array(2); - int index = 0; - - //Copy all the attributes into the array. - attrColl->CopyTo( arr, index ); - Console::WriteLine( "Display all the attributes in the array.." ); - System::Collections::IEnumerator^ myEnum = arr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlAttribute^ attr = safe_cast(myEnum->Current); - Console::WriteLine( "{0} = {1}", attr->Name, attr->Value ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertAfter Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertAfter Example/CPP/source.cpp deleted file mode 100644 index cef8075ba6b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertAfter Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create a new attribute. - XmlAttribute^ newAttr = doc->CreateAttribute( "genre" ); - newAttr->Value = "novel"; - - //Create an attribute collection and add the new attribute - //to the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->InsertAfter( newAttr, attrColl[ 0 ] ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertBefore Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertBefore Example/CPP/source.cpp deleted file mode 100644 index e83046a63b2..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertBefore Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create a new attribute. - XmlAttribute^ newAttr = doc->CreateAttribute( "genre" ); - newAttr->Value = "novel"; - - //Create an attribute collection and add the new attribute - //to the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->InsertBefore( newAttr, attrColl[ 0 ] ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Prepend Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Prepend Example/CPP/source.cpp deleted file mode 100644 index 58098e9636e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Prepend Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create a new attribute. - XmlAttribute^ newAttr = doc->CreateAttribute( "genre" ); - newAttr->Value = "novel"; - - //Create an attribute collection and add the new attribute - //to the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->Prepend( newAttr ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/CPP/source.cpp deleted file mode 100644 index 462904f2588..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection and remove an attribute - //from the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->Remove( attrColl[ "genre" ] ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAll Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAll Example/CPP/source.cpp deleted file mode 100644 index 6b44e2cdb0b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAll Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection and remove all attributes - //from the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->RemoveAll(); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAt Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAt Example/CPP/source.cpp deleted file mode 100644 index 852996d7f61..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAt Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection and remove an attribute - //from the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->RemoveAt( 0 ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.SetNamedItem Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.SetNamedItem Example/CPP/source.cpp deleted file mode 100644 index 1eeb8a09d55..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.SetNamedItem Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create a new attribute. - XmlAttribute^ newAttr = doc->CreateAttribute( "genre" ); - newAttr->Value = "novel"; - - //Create an attribute collection and add the new attribute - //to the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->SetNamedItem( newAttr ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/CPP/source.cpp deleted file mode 100644 index d05785cb9df..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - Console::WriteLine( "Display all the attributes in the collection...\r\n" ); - for ( int i = 0; i < attrColl->Count; i++ ) - { - Console::Write( "{0} = ", attrColl[ i ]->Name ); - Console::Write( "{0}", attrColl[ i ]->Value ); - Console::WriteLine(); - - } -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp deleted file mode 100644 index 65290b3374d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Define the order data. They will be converted to string - //before being written out. - Int16 custID = 32632; - String^ orderID = "367A54"; - DateTime orderDate = DateTime::Now; - Double price = 19.95; - - //Create a writer that outputs to the console. - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - - //Write an element (this one is the root) - writer->WriteStartElement( "order" ); - - //Write the order date. - writer->WriteAttributeString( "date", XmlConvert::ToString( orderDate, "yyyy-MM-dd" ) ); - - //Write the order time. - writer->WriteAttributeString( "time", XmlConvert::ToString( orderDate, "HH:mm:ss" ) ); - - //Write the order data. - writer->WriteElementString( "orderID", orderID ); - writer->WriteElementString( "custID", XmlConvert::ToString( custID ) ); - writer->WriteElementString( "price", XmlConvert::ToString( price ) ); - - //Write the close tag for the root element - writer->WriteEndElement(); - - //Write the XML and close the writer - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/CPP/source.cpp deleted file mode 100644 index e37f5167c22..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/CPP/source.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; -using namespace System::Data::SqlClient; -int main() -{ - DataSet^ dsNorthwind = gcnew DataSet; - - //Create the connection string. - String^ sConnect; - sConnect = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind"; - - //Create a connection object to connect to the northwind db. - SqlConnection^ nwconnect = gcnew SqlConnection( sConnect ); - - //Create a command string to select all the customers in the WA region. - String^ sCommand = "Select * from Customers where Region='WA'"; - - //Create an adapter to load the DataSet. - SqlDataAdapter^ myDataAdapter = gcnew SqlDataAdapter( sCommand,nwconnect ); - - //Fill the DataSet with the selected records. - myDataAdapter->Fill( dsNorthwind, "Customers" ); - - //Load the document with the DataSet. - XmlDataDocument^ doc = gcnew XmlDataDocument( dsNorthwind ); - - //Create a shallow clone of the XmlDataDocument. Note that although - //none of the child nodes were copied over, the cloned node does - //have the schema information. - XmlDataDocument^ clone = dynamic_cast(doc->CloneNode( false )); - Console::WriteLine( "Child count: {0}", clone->ChildNodes->Count ); - Console::WriteLine( clone->DataSet->GetXmlSchema() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/CPP/source.cpp deleted file mode 100644 index 8ef5454e02d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; - -int main() -{ - - //Create an XmlDataDocument. - XmlDataDocument^ doc = gcnew XmlDataDocument; - - //Load the schema file. - doc->DataSet->ReadXmlSchema( "store.xsd" ); - - //Load the XML data. - doc->Load( "2books.xml" ); - - //Update the price on the first book using the DataSet methods. - DataTable^ books = doc->DataSet->Tables[ "book" ]; - books->Rows[ 0 ][ "price" ] = "12.95"; - Console::WriteLine( "Display the modified XML data..." ); - doc->Save( Console::Out ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.GetElementFromRow Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.GetElementFromRow Example/CPP/source.cpp deleted file mode 100644 index 9ee8eb597d8..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.GetElementFromRow Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; -using namespace System::Data::SqlClient; - -int main() -{ - DataSet^ dsNorthwind = gcnew DataSet; - - //Create the connection string - String^ sConnect; - sConnect = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind"; - - //Create a connection object to connect to the northwind db. - SqlConnection^ nwconnect = gcnew SqlConnection( sConnect ); - - //Create a command string to select all the customers in the WA region. - String^ sCommand = "Select * from Customers where Region='WA'"; - - //Create an adapter to load the DataSet. - SqlDataAdapter^ myDataAdapter = gcnew SqlDataAdapter( sCommand,nwconnect ); - - //Fill the DataSet with the selected records. - myDataAdapter->Fill( dsNorthwind, "Customers" ); - - //Load the document with the DataSet. - XmlDataDocument^ doc = gcnew XmlDataDocument( dsNorthwind ); - - //Create an element representing the first customer record. - DataRow^ row = doc->DataSet->Tables[ 0 ]->Rows[ 0 ]; - XmlElement^ elem = doc->GetElementFromRow( row ); - Console::WriteLine( elem->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/CPP/source.cpp deleted file mode 100644 index efc4bd880c6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; -using namespace System::Data::SqlClient; -int main() -{ - DataSet^ dsNorthwind = gcnew DataSet; - - //Create the connection string. - String^ sConnect; - sConnect = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind"; - - //Create a connection object to connect to the northwind db. - SqlConnection^ nwconnect = gcnew SqlConnection( sConnect ); - - //Create a command string to select all the customers in the WA region. - String^ sCommand = "Select * from Customers where Region='WA'"; - - //Create an adapter to load the DataSet. - SqlDataAdapter^ myDataAdapter = gcnew SqlDataAdapter( sCommand,nwconnect ); - - //Fill the DataSet with the selected records. - myDataAdapter->Fill( dsNorthwind, "Customers" ); - - //Load the document with the DataSet. - XmlDataDocument^ doc = gcnew XmlDataDocument( dsNorthwind ); - - //Display the XmlDataDocument. - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Encoding Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Encoding Example/CPP/source.cpp deleted file mode 100644 index cf3fc8cd852..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Encoding Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - String^ xmlString = "Oberon's Legacy"; - doc->Load( gcnew StringReader( xmlString ) ); - - // Create an XML declaration. - XmlDeclaration^ xmldecl; - xmldecl = doc->CreateXmlDeclaration( "1.0", nullptr, nullptr ); - xmldecl->Encoding = "UTF-8"; - xmldecl->Standalone = "yes"; - - // Add the new node to the document. - XmlElement^ root = doc->DocumentElement; - doc->InsertBefore( xmldecl, root ); - - // Display the modified XML document - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Standalone Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Standalone Example/CPP/source.cpp deleted file mode 100644 index cf3fc8cd852..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Standalone Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - String^ xmlString = "Oberon's Legacy"; - doc->Load( gcnew StringReader( xmlString ) ); - - // Create an XML declaration. - XmlDeclaration^ xmldecl; - xmldecl = doc->CreateXmlDeclaration( "1.0", nullptr, nullptr ); - xmldecl->Encoding = "UTF-8"; - xmldecl->Standalone = "yes"; - - // Add the new node to the document. - XmlElement^ root = doc->DocumentElement; - doc->InsertBefore( xmldecl, root ); - - // Display the modified XML document - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/CPP/source.cpp deleted file mode 100644 index f4464977f99..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" ); - - // Create a document fragment. - XmlDocumentFragment^ docFrag = doc->CreateDocumentFragment(); - - // Set the contents of the document fragment. - docFrag->InnerXml = "widget"; - - // Create a deep clone. The cloned node - // includes child nodes. - XmlNode^ deep = docFrag->CloneNode( true ); - Console::WriteLine( "Name: {0}", deep->Name ); - Console::WriteLine( "OuterXml: {0}", deep->OuterXml ); - - // Create a shallow clone. The cloned node does - // not include any child nodes. - XmlNode^ shallow = docFrag->CloneNode( false ); - Console::WriteLine( "Name: {0}", shallow->Name ); - Console::WriteLine( "OuterXml: {0}", shallow->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.InnerXml Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.InnerXml Example/CPP/source.cpp deleted file mode 100644 index 28e3cfe2a6e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.InnerXml Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - - // Create a document fragment. - XmlDocumentFragment^ docFrag = doc->CreateDocumentFragment(); - - // Set the contents of the document fragment. - docFrag->InnerXml = "widget"; - - // Display the document fragment. - Console::WriteLine( docFrag->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.OwnerDocument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.OwnerDocument Example/CPP/source.cpp deleted file mode 100644 index 8c15797d0b5..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.OwnerDocument Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" ); - - // Create a document fragment. - XmlDocumentFragment^ docFrag = doc->CreateDocumentFragment(); - - // Display the owner document of the document fragment. - Console::WriteLine( docFrag->OwnerDocument->OuterXml ); - - // Add nodes to the document fragment. Notice that the - // new element is created using the owner document of - // the document fragment. - XmlElement^ elem = doc->CreateElement( "item" ); - elem->InnerText = "widget"; - docFrag->AppendChild( elem ); - Console::WriteLine( "Display the document fragment..." ); - Console::WriteLine( docFrag->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.IsReadOnly Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.IsReadOnly Example/CPP/source.cpp deleted file mode 100644 index 6c4328103ed..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.IsReadOnly Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "Pride And Prejudice" - "" - "" ); - - // Check if the node is read-only. - if ( doc->DocumentType->IsReadOnly ) - Console::WriteLine( "Document type nodes are always read-only" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.Name Example/CPP/source.cpp deleted file mode 100644 index 7c1b61160cd..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.Name Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "Pride And Prejudice" - "" - "" ); - - // Display information on the DocumentType node. - XmlDocumentType^ doctype = doc->DocumentType; - Console::WriteLine( "Name of the document type: {0}", doctype->Name ); - Console::WriteLine( "The internal subset of the document type: {0}", doctype->InternalSubset ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Attributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Attributes Example/CPP/source.cpp deleted file mode 100644 index 0b8dd71f455..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Attributes Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Change the value of the first attribute. - root->Attributes[ 0 ]->Value = "fiction"; - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/CPP/source.cpp deleted file mode 100644 index b75667b60fc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "2books.xml" ); - - // Create a new element. - XmlElement^ elem = doc->CreateElement( "misc" ); - elem->InnerText = "hardcover"; - elem->SetAttribute( "publisher", "WorldWide Publishing" ); - - // Clone the element so we can add one to each of the book nodes. - XmlNode^ elem2 = elem->CloneNode( true ); - - // Add the new elements. - doc->DocumentElement->FirstChild->AppendChild( elem ); - doc->DocumentElement->LastChild->AppendChild( elem2 ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetAttributeNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetAttributeNode Example/CPP/source.cpp deleted file mode 100644 index fc626a6df19..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetAttributeNode Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Check to see if the element has a genre attribute. - if ( root->HasAttribute( "genre" ) ) - { - XmlAttribute^ attr = root->GetAttributeNode( "genre" ); - Console::WriteLine( attr->Value ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp deleted file mode 100644 index 43426ae0dd2..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "2books.xml" ); - - // Get and display all the book titles. - XmlElement^ root = doc->DocumentElement; - XmlNodeList^ elemList = root->GetElementsByTagName( "title" ); - for ( int i = 0; i < elemList->Count; i++ ) - { - Console::WriteLine( elemList[ i ]->InnerXml ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttribute Example/CPP/source.cpp deleted file mode 100644 index ab87fd72095..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Check to see if the element has a genre attribute. - if ( root->HasAttribute( "genre" ) ) - { - String^ genre = root->GetAttribute( "genre" ); - Console::WriteLine( genre ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttributes Example/CPP/source.cpp deleted file mode 100644 index b0288ee6c7e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove all attributes from the root element. - if ( root->HasAttributes ) - root->RemoveAllAttributes(); - - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/CPP/source.cpp deleted file mode 100644 index 1c76c3bca01..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/CPP/source.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "some textmore text" ); - XmlElement^ elem = dynamic_cast(doc->DocumentElement->FirstChild); - - // Note that InnerText does not include the markup. - Console::WriteLine( "Display the InnerText of the element..." ); - Console::WriteLine( elem->InnerText ); - - // InnerXml includes the markup of the element. - Console::WriteLine( "Display the InnerXml of the element..." ); - Console::WriteLine( elem->InnerXml ); - - // Set InnerText to a string that includes markup. - // The markup is escaped. - elem->InnerText = "Text containing will have char(<) and char(>) escaped."; - Console::WriteLine( elem->OuterXml ); - - // Set InnerXml to a string that includes markup. - // The markup is not escaped. - elem->InnerXml = "Text containing ."; - Console::WriteLine( elem->OuterXml ); -} -// This example produces the following results: -// -// Display the InnerText of the element... -// some textmore text -// Display the InnerXml of the element... -// some textmore text -// Text containing <markup/> will have char(<) and char(>) escaped. -// Text containing . -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.IsEmpty Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.IsEmpty Example/CPP/source.cpp deleted file mode 100644 index 32d168f69fc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.IsEmpty Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " Pride And Prejudice " ); - XmlElement^ currNode = dynamic_cast(doc->DocumentElement->LastChild); - if ( currNode->IsEmpty ) - currNode->InnerXml = "19.95"; - - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp deleted file mode 100644 index 79d6693b5c4..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "1-861001-57-5" - "Pride And Prejudice" - "" ); - - // Display information on the ISBN element. - XmlElement^ elem = dynamic_cast(doc->DocumentElement->FirstChild); - Console::Write( "{0}:{1} = {2}", elem->Prefix, elem->LocalName, elem->InnerText ); - Console::WriteLine( "\t namespaceURI={0}", elem->NamespaceURI ); -} - -// This code produces the following output. -// bk:ISBN = 1-861001-57-5 namespaceURI=urn:samples -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CPP/source.cpp deleted file mode 100644 index 0523cdebda0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "1-861001-57-5" - "Pride And Prejudice" - "" ); - - // Display information on the ISBN element. - XmlElement^ elem = dynamic_cast(doc->DocumentElement->FirstChild); - Console::Write( "{0} = {1}", elem->Name, elem->InnerText ); - Console::WriteLine( "\t namespaceURI={0}", elem->NamespaceURI ); -} - -// This code produces the following output. -// bk:ISBN = 1-861001-57-5 namespaceURI=urn:samples -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.OwnerDocument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.OwnerDocument Example/CPP/source.cpp deleted file mode 100644 index 61bff069bb3..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.OwnerDocument Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Create a new element. - XmlElement^ elem = doc->CreateElement( "price" ); - elem->InnerText = "19.95"; - - // Display the new element's owner document. Note - // that although the element has not been inserted - // into the document, it still has an owner document. - Console::WriteLine( elem->OwnerDocument->OuterXml ); - - // Add the new element into the document. - root->AppendChild( elem ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAll Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAll Example/CPP/source.cpp deleted file mode 100644 index 55d58e8f4df..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAll Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - // Remove all attributes and child nodes from the book element. - XmlElement^ root = doc->DocumentElement; - root->RemoveAll(); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAllAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAllAttributes Example/CPP/source.cpp deleted file mode 100644 index b35acf816b6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAllAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove all attributes from the root element. - root->RemoveAllAttributes(); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute Example/CPP/source.cpp deleted file mode 100644 index b0464c9da27..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove the genre attribute. - root->RemoveAttribute( "genre" ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute1 Example/CPP/source.cpp deleted file mode 100644 index f16ed9f8182..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove the ISBN attribute. - root->RemoveAttribute( "ISBN", "urn:samples" ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeAt Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeAt Example/CPP/source.cpp deleted file mode 100644 index d65bd739012..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeAt Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove the genre attribute. - root->RemoveAttributeAt( 0 ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeNode1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeNode1 Example/CPP/source.cpp deleted file mode 100644 index 85f87dd21d6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeNode1 Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove the ISBN attribute. - root->RemoveAttributeNode( "ISBN", "urn:samples" ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/CPP/source.cpp deleted file mode 100644 index 495d6d0bedd..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Add a new attribute. - XmlAttribute^ attr = root->SetAttributeNode( "genre", "urn:samples" ); - attr->Value = "novel"; - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteContentTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteContentTo Example/CPP/source.cpp deleted file mode 100644 index 577c59e10dc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteContentTo Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Note that because WriteContentTo saves only the children of the element - // to the writer none of the attributes are displayed. - Console::WriteLine( "Display the contents of the element..." ); - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - root->WriteContentTo( writer ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteTo Example/CPP/source.cpp deleted file mode 100644 index dc693bbe781..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteTo Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Add a new attribute. - root->SetAttribute( "genre", "urn:samples", "novel" ); - Console::WriteLine( "Display the modified XML..." ); - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - root->WriteTo( writer ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/CPP/source.cpp deleted file mode 100644 index 557e86ed61a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "http://localhost/uri.xml" ); - - //Display information on the entity reference node. - XmlEntityReference^ entref = dynamic_cast(doc->DocumentElement->LastChild->FirstChild); - Console::WriteLine( "Name of the entity reference: {0}", entref->Name ); - Console::WriteLine( "Base URI of the entity reference: {0}", entref->BaseURI ); - Console::WriteLine( "The entity replacement text: {0}", entref->InnerText ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.IsReadOnly Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.IsReadOnly Example/CPP/source.cpp deleted file mode 100644 index 5df1512470f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.IsReadOnly Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "Pride And Prejudice" - "" - "" ); - - // Check if the node is read-only. - XmlEntityReference^ entref = dynamic_cast(doc->DocumentElement->LastChild->FirstChild); - if ( entref->IsReadOnly ) - Console::WriteLine( "Entity reference nodes are always read-only" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.Name Example/CPP/source.cpp deleted file mode 100644 index 0635eed93bf..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.Name Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "Pride And Prejudice" - "" - "" ); - - // Display information on the entity reference node. - XmlEntityReference^ entref = dynamic_cast(doc->DocumentElement->LastChild->FirstChild); - Console::WriteLine( "Name of the entity reference: {0}", entref->Name ); - Console::WriteLine( "The entity replacement text: {0}", entref->InnerText ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/CPP/source.cpp deleted file mode 100644 index 80c8c8c001b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Data; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - DataSet^ dataset; - -public: - void Method() - { -// - XmlImplementation^ imp = gcnew XmlImplementation; - XmlDocument^ doc1 = imp->CreateDocument(); - XmlDocument^ doc2 = imp->CreateDocument(); -// - } -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.NextSibling Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.NextSibling Example/CPP/source.cpp deleted file mode 100644 index da00cfebf0a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.NextSibling Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - - // Display the first two book nodes. - XmlNode^ book = doc->DocumentElement->FirstChild; - Console::WriteLine( book->OuterXml ); - Console::WriteLine(); - Console::WriteLine( book->NextSibling->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.PreviousSibling Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.PreviousSibling Example/CPP/source.cpp deleted file mode 100644 index 6b73208b236..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.PreviousSibling Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - XmlNode^ lastNode = doc->DocumentElement->LastChild; - Console::WriteLine( "Last book..." ); - Console::WriteLine( lastNode->OuterXml ); - XmlNode^ prevNode = lastNode->PreviousSibling; - Console::WriteLine( "\r\nPrevious book..." ); - Console::WriteLine( prevNode->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/CPP/source.cpp deleted file mode 100644 index 284b8359eb1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " Pride And Prejudice" ); - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - Console::WriteLine( "Display all the attributes for this book..." ); - for ( int i = 0; i < attrColl->Count; i++ ) - { - Console::WriteLine( "{0} = {1}", attrColl->Item( i )->Name, attrColl->Item( i )->Value ); - - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetEnumerator Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetEnumerator Example/CPP/source.cpp deleted file mode 100644 index 4d3bd90411a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetEnumerator Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Collections; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - " Pride And Prejudice" - "" ); - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - Console::WriteLine( "Display all the attributes for this book..." ); - IEnumerator^ ienum = attrColl->GetEnumerator(); - while ( ienum->MoveNext() ) - { - XmlAttribute^ attr = dynamic_cast(ienum->Current); - Console::WriteLine( "{0} = {1}", attr->Name, attr->Value ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/CPP/source.cpp deleted file mode 100644 index 0f47e848c12..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " Pride And Prejudice" ); - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - - // Change the value for the genre attribute. - XmlAttribute^ attr = dynamic_cast(attrColl->GetNamedItem( "genre" )); - attr->Value = "fiction"; - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/CPP/source.cpp deleted file mode 100644 index 8850c3b5bc0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " Pride And Prejudice" ); - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - - // Remove the publicationdate attribute. - attrColl->RemoveNamedItem( "publicationdate" ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/CPP/source.cpp deleted file mode 100644 index 6dda24559d4..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " Pride And Prejudice" ); - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - - // Add a new attribute to the collection. - XmlAttribute^ attr = doc->CreateAttribute( "style" ); - attr->Value = "hardcover"; - attrColl->SetNamedItem( attr ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/CPP/source.cpp deleted file mode 100644 index e1cf039093e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Data; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - DataSet^ dataset; - -public: - void Method( XmlNamespaceManager^ nsmgr ) - { -// - if ( nsmgr->HasNamespace( String::Empty ) ) - { - Console::WriteLine( nsmgr->DefaultNamespace ); - } -// - } -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp deleted file mode 100644 index 38bee9fe649..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -public: - Sample() - { - - // Create the XmlNamespaceManager. - NameTable^ nt = gcnew NameTable; - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt ); - - // Add prefix/namespace pairs to the XmlNamespaceManager. - nsmgr->AddNamespace( "", "www.wideworldimporters.com" ); //Adds a default namespace. - nsmgr->AddNamespace( "europe", "www.wideworldimporters.com/europe" ); - nsmgr->PushScope(); //Pushes a namespace scope on the stack. - nsmgr->AddNamespace( "", "www.lucernepublishing.com" ); //Adds another default namespace. - nsmgr->AddNamespace( "partners", "www.lucernepublishing.com/partners" ); - Console::WriteLine( "Show all the prefix/namespace pairs in the XmlNamespaceManager..." ); - ShowAllNamespaces( nsmgr ); - } - - -private: - void ShowAllNamespaces( XmlNamespaceManager^ nsmgr ) - { - do - { - System::Collections::IEnumerator^ myEnum = nsmgr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ prefix = safe_cast(myEnum->Current); - Console::WriteLine( "Prefix={0}, Namespace={1}", prefix, nsmgr->LookupNamespace( prefix ) ); - } - } - while ( nsmgr->PopScope() ); - } - -}; - -int main() -{ - gcnew Sample; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.XmlNamespaceManager Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.XmlNamespaceManager Example/CPP/source.cpp deleted file mode 100644 index 7e0abed5a53..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.XmlNamespaceManager Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; -using namespace System::Xml::Schema; -public ref class Class1 -{ -public: - void Method1() - { - - // - XmlTextReader^ reader = gcnew XmlTextReader( "myfile.xml" ); - XmlNamespaceManager^ nsmanager = gcnew XmlNamespaceManager( reader->NameTable ); - nsmanager->AddNamespace( "msbooks", "www.microsoft.com/books" ); - nsmanager->PushScope(); - nsmanager->AddNamespace( "msstore", "www.microsoft.com/store" ); - while ( reader->Read() ) - { - Console::WriteLine( "Reader Prefix:{0}", reader->Prefix ); - Console::WriteLine( "XmlNamespaceManager Prefix:{0}", nsmanager->LookupPrefix( nsmanager->NameTable->Get( reader->NamespaceURI ) ) ); - } - } - -}; - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.AppendChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.AppendChild Example/CPP/source.cpp deleted file mode 100644 index cc33f1ca5ec..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.AppendChild Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Create a new node. - XmlElement^ elem = doc->CreateElement( "price" ); - elem->InnerText = "19.95"; - - //Add the node to the document. - root->AppendChild( elem ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.Clone Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.Clone Example/CPP/source.cpp deleted file mode 100644 index 0e20454fc0c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.Clone Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - - //Clone the root node. The cloned node includes - //child nodes. This is similar to calling CloneNode(true). - XmlNode^ clone = root->Clone(); - Console::WriteLine( clone->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.CloneNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.CloneNode Example/CPP/source.cpp deleted file mode 100644 index 5d3608a3e74..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.CloneNode Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - - //Create a deep clone. The cloned node - //includes the child nodes. - XmlNode^ deep = root->CloneNode( true ); - Console::WriteLine( deep->OuterXml ); - - //Create a shallow clone. The cloned node does not - //include the child nodes, but does include its attribute. - XmlNode^ shallow = root->CloneNode( false ); - Console::WriteLine( shallow->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.FirstChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.FirstChild Example/CPP/source.cpp deleted file mode 100644 index 8c9bb154ef8..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.FirstChild Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - Console::WriteLine( "Display the title element..." ); - Console::WriteLine( root->FirstChild->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetEnumerator Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetEnumerator Example/CPP/source.cpp deleted file mode 100644 index b7fb2e4d051..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetEnumerator Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - Console::WriteLine( "Display all the books..." ); - XmlNode^ root = doc->DocumentElement; - IEnumerator^ ienum = root->GetEnumerator(); - XmlNode^ book; - while ( ienum->MoveNext() ) - { - book = dynamic_cast(ienum->Current); - Console::WriteLine( book->OuterXml ); - Console::WriteLine(); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp deleted file mode 100644 index 7f8efa23a79..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->FirstChild; - - //Create a new attribute. - String^ ns = root->GetNamespaceOfPrefix( "bk" ); - XmlNode^ attr = doc->CreateNode( XmlNodeType::Attribute, "genre", ns ); - attr->Value = "novel"; - - //Add the attribute to the document. - root->Attributes->SetNamedItem( attr ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetPrefixOfNamespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetPrefixOfNamespace Example/CPP/source.cpp deleted file mode 100644 index 24c5ad1996b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetPrefixOfNamespace Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->FirstChild; - - //Create a new node. - String^ prefix = root->GetPrefixOfNamespace( "urn:samples" ); - XmlElement^ elem = doc->CreateElement( prefix, "style", "urn:samples" ); - elem->InnerText = "hardcover"; - - //Add the node to the document. - root->AppendChild( elem ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/CPP/source.cpp deleted file mode 100644 index ff8ddddef56..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - - //Display the contents of the child nodes. - if ( root->HasChildNodes ) - { - for ( int i = 0; i < root->ChildNodes->Count; i++ ) - { - Console::WriteLine( root->ChildNodes[ i ]->InnerText ); - } - } -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/CPP/source.cpp deleted file mode 100644 index afa0e8a8997..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "some textmore text" - "" ); - XmlNode^ elem = doc->DocumentElement->FirstChild; - - // Note that InnerText does not include the markup. - Console::WriteLine( "Display the InnerText of the element..." ); - Console::WriteLine( elem->InnerText ); - - // InnerXml includes the markup of the element. - Console::WriteLine( "Display the InnerXml of the element..." ); - Console::WriteLine( elem->InnerXml ); - - // Set InnerText to a string that includes markup. - // The markup is escaped. - elem->InnerText = "Text containing will have char(<) and char(>) escaped."; - Console::WriteLine( elem->OuterXml ); - - // Set InnerXml to a string that includes markup. - // The markup is not escaped. - elem->InnerXml = "Text containing ."; - Console::WriteLine( elem->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertAfter Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertAfter Example/CPP/source.cpp deleted file mode 100644 index bbc72ef7e69..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertAfter Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Create a new node. - XmlElement^ elem = doc->CreateElement( "price" ); - elem->InnerText = "19.95"; - - //Add the node to the document. - root->InsertAfter( elem, root->FirstChild ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertBefore Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertBefore Example/CPP/source.cpp deleted file mode 100644 index 3ebee800a51..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertBefore Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Create a new node. - XmlElement^ elem = doc->CreateElement( "price" ); - elem->InnerText = "19.95"; - - //Add the node to the document. - root->InsertBefore( elem, root->FirstChild ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.LastChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.LastChild Example/CPP/source.cpp deleted file mode 100644 index 9514236fc62..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.LastChild Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - Console::WriteLine( "Display the price element..." ); - Console::WriteLine( root->LastChild->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.NextSibling Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.NextSibling Example/CPP/source.cpp deleted file mode 100644 index c78113a0dab..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.NextSibling Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - XmlNode^ currNode = doc->DocumentElement->FirstChild; - Console::WriteLine( "First book..." ); - Console::WriteLine( currNode->OuterXml ); - XmlNode^ nextNode = currNode->NextSibling; - Console::WriteLine( "\r\nSecond book..." ); - Console::WriteLine( nextNode->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.OuterXml Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.OuterXml Example/CPP/source.cpp deleted file mode 100644 index 9465dbc7815..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.OuterXml Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - // OuterXml includes the markup of current node. - Console::WriteLine( "Display the OuterXml property..." ); - Console::WriteLine( root->OuterXml ); - - // InnerXml does not include the markup of the current node. - // As a result, the attributes are not displayed. - Console::WriteLine(); - Console::WriteLine( "Display the InnerXml property..." ); - Console::WriteLine( root->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PrependChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PrependChild Example/CPP/source.cpp deleted file mode 100644 index 63c23bf93d4..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PrependChild Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Create a new node. - XmlElement^ elem = doc->CreateElement( "price" ); - elem->InnerText = "19.95"; - - //Add the node to the document. - root->PrependChild( elem ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PreviousSibling Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PreviousSibling Example/CPP/source.cpp deleted file mode 100644 index 6b73208b236..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PreviousSibling Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - XmlNode^ lastNode = doc->DocumentElement->LastChild; - Console::WriteLine( "Last book..." ); - Console::WriteLine( lastNode->OuterXml ); - XmlNode^ prevNode = lastNode->PreviousSibling; - Console::WriteLine( "\r\nPrevious book..." ); - Console::WriteLine( prevNode->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveAll Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveAll Example/CPP/source.cpp deleted file mode 100644 index 5d7402c67e9..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveAll Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Remove all attribute and child nodes. - root->RemoveAll(); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveChild Example/CPP/source.cpp deleted file mode 100644 index 3eeeb8ee336..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveChild Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Remove the title element. - root->RemoveChild( root->FirstChild ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.ReplaceChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.ReplaceChild Example/CPP/source.cpp deleted file mode 100644 index 8b2b88dc130..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.ReplaceChild Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Create a new title element. - XmlElement^ elem = doc->CreateElement( "title" ); - elem->InnerText = "The Handmaid's Tale"; - - //Replace the title element. - root->ReplaceChild( elem, root->FirstChild ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectNodes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectNodes Example/CPP/source.cpp deleted file mode 100644 index fa145876295..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectNodes Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "booksort.xml" ); - XmlNodeList^ nodeList; - XmlNode^ root = doc->DocumentElement; - nodeList = root->SelectNodes( "descendant::book[author/last-name='Austen']" ); - - //Change the price on the books. - System::Collections::IEnumerator^ myEnum = nodeList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlNode^ book = safe_cast(myEnum->Current); - book->LastChild->InnerText = "15.95"; - } - - Console::WriteLine( "Display the modified XML document...." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectSingleNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectSingleNode Example/CPP/source.cpp deleted file mode 100644 index 7ef2af1b754..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectSingleNode Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "booksort.xml" ); - XmlNode^ book; - XmlNode^ root = doc->DocumentElement; - book = root->SelectSingleNode( "descendant::book[author/last-name='Austen']" ); - - //Change the price on the book. - book->LastChild->InnerText = "15.95"; - Console::WriteLine( "Display the modified XML document...." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteContentTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteContentTo Example/CPP/source.cpp deleted file mode 100644 index 109df9f1d9a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteContentTo Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->FirstChild; - - // Because WriteContentTo saves only the child nodes of the node - // to the writer none of the attributes are displayed. - Console::WriteLine( "Display the contents of the node..." ); - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - root->WriteContentTo( writer ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteTo Example/CPP/source.cpp deleted file mode 100644 index 7a871794b8e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteTo Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->FirstChild; - Console::WriteLine( "Display the root node..." ); - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - root->WriteTo( writer ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.this Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.this Example/CPP/source.cpp deleted file mode 100644 index d308ff6a9b0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.this Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - Console::WriteLine( "Display the title element..." ); - Console::WriteLine( root[ "title" ]->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.GetEnumerator Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.GetEnumerator Example/CPP/source.cpp deleted file mode 100644 index 931cd16856c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.GetEnumerator Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Collections; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "2books.xml" ); - - //Get and display all the book titles. - XmlElement^ root = doc->DocumentElement; - XmlNodeList^ elemList = root->GetElementsByTagName( "title" ); - IEnumerator^ ienum = elemList->GetEnumerator(); - while ( ienum->MoveNext() ) - { - XmlNode^ title = dynamic_cast(ienum->Current); - Console::WriteLine( title->InnerText ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.Item Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.Item Example/CPP/source.cpp deleted file mode 100644 index 8fcc0d2c019..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.Item Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - " First item" - " Second item" - "" ); - - //Get and display the last item node. - XmlElement^ root = doc->DocumentElement; - XmlNodeList^ nodeList = root->GetElementsByTagName( "item" ); - Console::WriteLine( nodeList->Item( 1 )->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp deleted file mode 100644 index 91353be15eb..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " " - "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Read the attributes on the root element. - reader->MoveToContent(); - if ( reader->HasAttributes ) - { - for ( int i = 0; i < reader->AttributeCount; i++ ) - { - reader->MoveToAttribute( i ); - Console::WriteLine( "{0} = {1}", reader->Name, reader->Value ); - - } - reader->MoveToElement(); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.BaseURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.BaseURI Example/CPP/source.cpp deleted file mode 100644 index d3287716081..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.BaseURI Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load an XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "http://localhost/uri.xml" ); - reader = gcnew XmlNodeReader( doc ); - - //Parse the file and display the base URI for each node. - while ( reader->Read() ) - { - Console::WriteLine( "({0}) {1}", reader->NodeType, reader->BaseURI ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.GetAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.GetAttribute Example/CPP/source.cpp deleted file mode 100644 index 5b0e8725b23..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.GetAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " " - "" ); - - // Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Read the ISBN attribute. - reader->MoveToContent(); - String^ isbn = reader->GetAttribute( "ISBN" ); - Console::WriteLine( "The ISBN value: {0}", isbn ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.HasValue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.HasValue Example/CPP/source.cpp deleted file mode 100644 index 009705ea4c1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.HasValue Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - // Create and load an XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "]>" - "" - "Pride And Prejudice" - "&h;" - "" ); - reader = gcnew XmlNodeReader( doc ); - - // Parse the file and display each node. - while ( reader->Read() ) - { - if ( reader->HasValue ) - Console::WriteLine( "({0}) {1}={2}", reader->NodeType, reader->Name, reader->Value ); - else - Console::WriteLine( "({0}) {1}", reader->NodeType, reader->Name ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/CPP/source.cpp deleted file mode 100644 index a63f00d1f68..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" - "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Parse the XML and display the text content of each of the elements. - while ( reader->Read() ) - { - if ( reader->IsStartElement() ) - { - if ( reader->IsEmptyElement ) - Console::WriteLine( "<{0}/>", reader->Name ); - else - { - Console::Write( "<{0}> ", reader->Name ); - reader->Read(); //Read the start tag. - if ( reader->IsStartElement() ) - - //Handle nested elements. - Console::Write( "\r\n<{0}>", reader->Name ); - Console::WriteLine( reader->ReadString() ); //Read the text content of the element. - } - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToFirstAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToFirstAttribute Example/CPP/source.cpp deleted file mode 100644 index 255f2c6a1da..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToFirstAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Read the genre attribute. - reader->MoveToContent(); - reader->MoveToFirstAttribute(); - String^ genre = reader->Value; - Console::WriteLine( "The genre value: {0}", genre ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToNextAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToNextAttribute Example/CPP/source.cpp deleted file mode 100644 index 2d6857ce16e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToNextAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " " - "Pride And Prejudice" - "19.95" - "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Read the attributes on the book element. - reader->MoveToContent(); - while ( reader->MoveToNextAttribute() ) - { - Console::WriteLine( "{0} = {1}", reader->Name, reader->Value ); - } - - //Move the reader to the title element. - reader->Read(); - - //Read the title and price elements. - Console::WriteLine( reader->ReadElementString() ); - Console::WriteLine( reader->ReadElementString() ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp deleted file mode 100644 index b596f0cbf8c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - String^ filename = "items.xml"; - XmlNodeReader^ reader = nullptr; - try - { - - //Create an XmlNodeReader to read the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( filename ); - reader = gcnew XmlNodeReader( doc ); - - //Parse the file and display each of the nodes. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( "<{0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( reader->Value ); - break; - - case XmlNodeType::CDATA: - Console::Write( reader->Value ); - break; - - case XmlNodeType::ProcessingInstruction: - Console::Write( "", reader->Name, reader->Value ); - break; - - case XmlNodeType::Comment: - Console::Write( "", reader->Value ); - break; - - case XmlNodeType::XmlDeclaration: - Console::Write( "" ); - break; - - case XmlNodeType::Document: - break; - - case XmlNodeType::EndElement: - Console::Write( "", reader->Name ); - break; - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp deleted file mode 100644 index 209660c6243..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp +++ /dev/null @@ -1,49 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " " - "Pride And Prejudice" - "novel" - "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Parse the XML. If they exist, display the prefix and - //namespace URI of each node. - while ( reader->Read() ) - { - if ( reader->IsStartElement() ) - { - if ( reader->Prefix == String::Empty ) - Console::WriteLine( "<{0}>", reader->LocalName ); - else - { - Console::Write( "<{0}:{1}>", reader->Prefix, reader->LocalName ); - Console::WriteLine( " The namespace URI is {0}", reader->NamespaceURI ); - } - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ReadAttributeValue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ReadAttributeValue Example/CPP/source.cpp deleted file mode 100644 index fa8f90ee268..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ReadAttributeValue Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load an XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "" ); - - //Create the reader. - reader = gcnew XmlNodeReader( doc ); - - //Read the misc attribute. The attribute is parsed into multiple - //text and entity reference nodes. - reader->MoveToContent(); - reader->MoveToAttribute( "misc" ); - while ( reader->ReadAttributeValue() ) - { - if ( reader->NodeType == XmlNodeType::EntityReference ) - - //To expand the entity, call ResolveEntity. - Console::WriteLine( "{0} {1}", reader->NodeType, reader->Name ); - else - Console::WriteLine( "{0} {1}", reader->NodeType, reader->Value ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ResolveEntity Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ResolveEntity Example/CPP/source.cpp deleted file mode 100644 index a980ac2665e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ResolveEntity Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load an XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "Pride And Prejudice" - "&h;" - "" ); - - //Create the reader. - reader = gcnew XmlNodeReader( doc ); - reader->MoveToContent(); //Move to the root element. - reader->Read(); //Move to title start tag. - reader->Skip(); //Skip the title element. - - //Read the misc start tag. The reader is now positioned on - //the entity reference node. - reader->ReadStartElement(); - - //You must call ResolveEntity to expand the entity reference. - //The entity replacement text is then parsed and returned as a child node. - Console::WriteLine( "Expand the entity..." ); - reader->ResolveEntity(); - Console::WriteLine( "The entity replacement text is returned as a text node." ); - reader->Read(); - Console::WriteLine( "NodeType: {0} Value: {1}", reader->NodeType, reader->Value ); - Console::WriteLine( "An EndEntity node closes the entity reference scope." ); - reader->Read(); - Console::WriteLine( "NodeType: {0} Name: {1}", reader->NodeType, reader->Name ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Skip Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Skip Example/CPP/source.cpp deleted file mode 100644 index cb90b873442..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Skip Example/CPP/source.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "" - "Pride And Prejudice" - "19.95" - "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - reader->MoveToContent(); //Move to the book node. - reader->Read(); //Read the book start tag. - reader->Skip(); //Skip the title element. - Console::WriteLine( reader->ReadOuterXml() ); //Read the price element. - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.HasAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.HasAttributes Example/CPP/source.cpp deleted file mode 100644 index 7658108b64d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.HasAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; -using namespace System::Xml::Schema; - -public ref class Class1 -{ -// -public: - void DisplayAttributes( XmlReader^ reader ) - { - if ( reader->HasAttributes ) - { - Console::WriteLine( "Attributes of <{0}>", reader->Name ); - while ( reader->MoveToNextAttribute() ) - { - Console::WriteLine( " {0}={1}", reader->Name, reader->Value ); - } - } - } -// -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/CPP/source.cpp deleted file mode 100644 index 4d1aa635c0e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - //Load the reader with the XML file. - reader = gcnew XmlTextReader( "elems.xml" ); - - //Parse the XML and display the text content of each of the elements. - while ( reader->Read() ) - { - if ( reader->IsStartElement() ) - { - if ( reader->IsEmptyElement ) - Console::WriteLine( "<{0}/>", reader->Name ); - else - { - Console::Write( "<{0}> ", reader->Name ); - reader->Read(); //Read the start tag. - if ( reader->IsStartElement() ) - - //Handle nested elements. - Console::Write( "\r\n<{0}>", reader->Name ); - Console::WriteLine( reader->ReadString() ); //Read the text content of the element. - } - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.MoveToContent Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.MoveToContent Example/CPP/source.cpp deleted file mode 100644 index 05bb06db971..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.MoveToContent Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Data; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - String^ _price; - -public: - void Method( XmlReader^ reader ) - { -// - if ( reader->MoveToContent() == XmlNodeType::Element && - reader->Name->Equals( "price" ) ) - { - _price = reader->ReadString(); - } -// - } -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchema Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchema Example/CPP/source.cpp deleted file mode 100644 index 2ecb603c997..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchema Example/CPP/source.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - static void Main() - { - - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ elementCat = gcnew XmlSchemaElement(); - schema->Items->Add(elementCat); - elementCat->Name = "cat"; - elementCat->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementDog); - elementDog->Name = "dog"; - elementDog->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementRedDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementRedDog); - elementRedDog->Name = "redDog"; - elementRedDog->SubstitutionGroup = gcnew XmlQualifiedName("dog"); - - // - XmlSchemaElement^ elementBrownDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementBrownDog); - elementBrownDog->Name = "brownDog"; - elementBrownDog->SubstitutionGroup = gcnew XmlQualifiedName("dog"); - - - // - XmlSchemaElement^ elementPets = gcnew XmlSchemaElement(); - schema->Items->Add(elementPets); - elementPets->Name = "pets"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - elementPets->SchemaType = complexType; - - // - XmlSchemaChoice^ choice = gcnew XmlSchemaChoice(); - complexType->Particle = choice; - choice->MinOccurs = 0; - choice->MaxOccursString = "unbounded"; - - // - XmlSchemaElement^ catRef = gcnew XmlSchemaElement(); - choice->Items->Add(catRef); - catRef->RefName = gcnew XmlQualifiedName("cat"); - - // - XmlSchemaElement^ dogRef = gcnew XmlSchemaElement(); - choice->Items->Add(dogRef); - dogRef->RefName = gcnew XmlQualifiedName("dog"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// - - diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/CPP/source.cpp deleted file mode 100644 index d410a9785b7..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/CPP/source.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - XmlSchemaElement^ thing1 = gcnew XmlSchemaElement(); - thing1->Name = "thing1"; - thing1->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - schema->Items->Add(thing1); - - XmlSchemaElement^ thing2 = gcnew XmlSchemaElement(); - thing2->Name = "thing2"; - thing2->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - schema->Items->Add(thing2); - - XmlSchemaElement^ thing3 = gcnew XmlSchemaElement(); - thing3->Name = "thing3"; - thing3->SchemaTypeName = - gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - schema->Items->Add(thing3); - - XmlSchemaElement^ thing4 = gcnew XmlSchemaElement(); - thing4->Name = "thing4"; - thing4->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - schema->Items->Add(thing4); - - XmlSchemaAttribute^ myAttribute = gcnew XmlSchemaAttribute(); - myAttribute->Name = "myAttribute"; - myAttribute->SchemaTypeName = gcnew XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema"); - schema->Items->Add(myAttribute); - - XmlSchemaComplexType^ myComplexType = gcnew XmlSchemaComplexType(); - myComplexType->Name = "myComplexType"; - - XmlSchemaAll^ complexType_all = gcnew XmlSchemaAll(); - - XmlSchemaElement^ complexType_all_thing1 = gcnew XmlSchemaElement(); - complexType_all_thing1->RefName = gcnew XmlQualifiedName("thing1", ""); - complexType_all->Items->Add(complexType_all_thing1); - - XmlSchemaElement^ complexType_all_thing2 = gcnew XmlSchemaElement(); - complexType_all_thing2->RefName = gcnew XmlQualifiedName("thing2", ""); - complexType_all->Items->Add(complexType_all_thing2); - - XmlSchemaElement^ complexType_all_thing3 = gcnew XmlSchemaElement(); - complexType_all_thing3->RefName = gcnew XmlQualifiedName("thing3", ""); - complexType_all->Items->Add(complexType_all_thing3); - - XmlSchemaElement^ complexType_all_thing4 = gcnew XmlSchemaElement(); - complexType_all_thing4->RefName = gcnew XmlQualifiedName("thing4", ""); - complexType_all->Items->Add(complexType_all_thing4); - - myComplexType->Particle = complexType_all; - - XmlSchemaAttribute^ complexType_myAttribute = gcnew XmlSchemaAttribute(); - complexType_myAttribute->RefName = gcnew XmlQualifiedName("myAttribute", ""); - myComplexType->Attributes->Add(complexType_myAttribute); - - schema->Items->Add(myComplexType); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/CPP/source.cpp deleted file mode 100644 index 0da1a34fd86..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/CPP/source.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - static void Main() - { - - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ simpleType = gcnew XmlSchemaSimpleType(); - simpleType->Name = "northwestStates"; - schema->Items->Add(simpleType); - - // - XmlSchemaAnnotation^ annNorthwestStates = gcnew XmlSchemaAnnotation(); - simpleType->Annotation = annNorthwestStates; - - // States in the Pacific Northwest of US - XmlSchemaDocumentation^ docNorthwestStates = gcnew XmlSchemaDocumentation(); - annNorthwestStates->Items->Add(docNorthwestStates); - docNorthwestStates->Markup = TextToNodeArray("States in the Pacific Northwest of US"); - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - simpleType->Content = restriction; - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaEnumerationFacet^ enumerationWA = gcnew XmlSchemaEnumerationFacet(); - restriction->Facets->Add(enumerationWA); - enumerationWA->Value = "WA"; - - // - XmlSchemaAnnotation^ annWA = gcnew XmlSchemaAnnotation(); - enumerationWA->Annotation = annWA; - - // Washington - XmlSchemaDocumentation^ docWA = gcnew XmlSchemaDocumentation(); - annWA->Items->Add(docWA); - docWA->Markup = TextToNodeArray("Washington"); - - // - XmlSchemaEnumerationFacet^ enumerationOR = gcnew XmlSchemaEnumerationFacet(); - restriction->Facets->Add(enumerationOR); - enumerationOR->Value = "OR"; - - // - XmlSchemaAnnotation^ annOR = gcnew XmlSchemaAnnotation(); - enumerationOR->Annotation = annOR; - - // Oregon - XmlSchemaDocumentation^ docOR = gcnew XmlSchemaDocumentation(); - annOR->Items->Add(docOR); - docOR->Markup = TextToNodeArray("Oregon"); - - // - XmlSchemaEnumerationFacet^ enumerationID = gcnew XmlSchemaEnumerationFacet(); - - restriction->Facets->Add(enumerationID); - enumerationID->Value = "ID"; - - // - XmlSchemaAnnotation^ annID = gcnew XmlSchemaAnnotation(); - enumerationID->Annotation = annID; - - // Idaho - XmlSchemaDocumentation^ docID = gcnew XmlSchemaDocumentation(); - annID->Items->Add(docID); - docID->Markup = TextToNodeArray("Idaho"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - - static array^ TextToNodeArray(String^ text) - { - XmlDocument^ doc = gcnew XmlDocument(); - array^ temp = {doc->CreateTextNode(text)}; - return temp; - } - -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAny Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAny Example/CPP/source.cpp deleted file mode 100644 index de4222ca95d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAny Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ xeHtmlText = gcnew XmlSchemaElement(); - xeHtmlText->Name = "htmlText"; - - // - XmlSchemaComplexType^ ct = gcnew XmlSchemaComplexType(); - - // - XmlSchemaSequence^ sequence = gcnew XmlSchemaSequence(); - - // - XmlSchemaAny^ any = gcnew XmlSchemaAny(); - any->MinOccurs = 1; - any->MaxOccursString = "unbounded"; - any->Namespace = "http://www.w3.org/1999/xhtml"; - any->ProcessContents = XmlSchemaContentProcessing::Lax; - sequence->Items->Add(any); - - ct->Particle = sequence; - xeHtmlText->SchemaType = ct; - - schema->Items->Add(xeHtmlText); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - schema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnyAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnyAttribute Example/CPP/source.cpp deleted file mode 100644 index 17a9abb810d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnyAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - schema->Items->Add(element); - element->Name = "stringElementWithAnyAttribute"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - element->SchemaType = complexType; - - // - XmlSchemaSimpleContent^ simpleContent = gcnew XmlSchemaSimpleContent(); - complexType->ContentModel = simpleContent; - - // - XmlSchemaSimpleContentExtension^ extension = gcnew XmlSchemaSimpleContentExtension(); - simpleContent->Content = extension; - extension->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAnyAttribute^ anyAttribute = gcnew XmlSchemaAnyAttribute(); - extension->AnyAttribute = anyAttribute; - anyAttribute->Namespace = "##targetNamespace"; - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAppInfo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAppInfo Example/CPP/source.cpp deleted file mode 100644 index cb4bdbb1014..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAppInfo Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - schema->Items->Add(element); - element->Name = "State"; - - // - XmlSchemaAnnotation^ annNorthwestStates = gcnew XmlSchemaAnnotation(); - element->Annotation = annNorthwestStates; - - // State Name - XmlSchemaDocumentation^ docNorthwestStates = gcnew XmlSchemaDocumentation(); - annNorthwestStates->Items->Add(docNorthwestStates); - docNorthwestStates->Markup = TextToNodeArray("State Name"); - - // Application Information - XmlSchemaAppInfo^ appInfo = gcnew XmlSchemaAppInfo(); - annNorthwestStates->Items->Add(appInfo); - appInfo->Markup = TextToNodeArray("Application Information"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - - Console::WriteLine(args->Message); - } - - static array^ TextToNodeArray(String^ text) - { - XmlDocument^ doc = gcnew XmlDocument(); - array^ nodes = {doc->CreateTextNode(text)}; - return nodes; - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttribute Example/CPP/source.cpp deleted file mode 100644 index 083c98e686d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaAttribute^ attributeBase = gcnew XmlSchemaAttribute(); - schema->Items->Add(attributeBase); - attributeBase->Name = "mybaseattribute"; - - // - XmlSchemaSimpleType^ simpleType = gcnew XmlSchemaSimpleType(); - attributeBase->SchemaType = simpleType; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - simpleType->Content = restriction; - restriction->BaseTypeName = gcnew XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMaxInclusiveFacet^ maxInclusive = gcnew XmlSchemaMaxInclusiveFacet(); - restriction->Facets->Add(maxInclusive); - maxInclusive->Value = "1000"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - schema->Items->Add(complexType); - complexType->Name = "myComplexType"; - - // - XmlSchemaAttribute^ attributeBaseRef = gcnew XmlSchemaAttribute(); - complexType->Attributes->Add(attributeBaseRef); - attributeBaseRef->RefName = gcnew XmlQualifiedName("mybaseattribute"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttributeGroup Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttributeGroup Example/CPP/source.cpp deleted file mode 100644 index 465d8de18d4..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttributeGroup Example/CPP/source.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaAttributeGroup^ myAttributeGroup = gcnew XmlSchemaAttributeGroup(); - schema->Items->Add(myAttributeGroup); - myAttributeGroup->Name = "myAttributeGroup"; - - // - XmlSchemaAttribute^ someattribute1 = gcnew XmlSchemaAttribute(); - myAttributeGroup->Attributes->Add(someattribute1); - someattribute1->Name = "someattribute1"; - someattribute1->SchemaTypeName = gcnew XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema"); - - - // - XmlSchemaAttribute^ someattribute2 = gcnew XmlSchemaAttribute(); - myAttributeGroup->Attributes->Add(someattribute2); - someattribute2->Name = "someattribute2"; - someattribute2->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaComplexType^ myElementType = gcnew XmlSchemaComplexType(); - schema->Items->Add(myElementType); - myElementType->Name = "myElementType"; - - // - XmlSchemaAttributeGroupRef^ myAttributeGroupRef = gcnew XmlSchemaAttributeGroupRef(); - myElementType->Attributes->Add(myAttributeGroupRef); - myAttributeGroupRef->RefName = gcnew XmlQualifiedName("myAttributeGroup"); - - // - XmlSchemaAttributeGroup^ myAttributeGroupA = gcnew XmlSchemaAttributeGroup(); - schema->Items->Add(myAttributeGroupA); - myAttributeGroupA->Name = "myAttributeGroupA"; - - // - XmlSchemaAttribute^ someattribute10 = gcnew XmlSchemaAttribute(); - myAttributeGroupA->Attributes->Add(someattribute10); - someattribute10->Name = "someattribute10"; - someattribute10->SchemaTypeName = gcnew XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAttribute^ someattribute11 = gcnew XmlSchemaAttribute(); - myAttributeGroupA->Attributes->Add(someattribute11); - someattribute11->Name = "someattribute11"; - someattribute11->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAttributeGroup^ myAttributeGroupB = gcnew XmlSchemaAttributeGroup(); - schema->Items->Add(myAttributeGroupB); - myAttributeGroupB->Name = "myAttributeGroupB"; - - // - XmlSchemaAttribute^ someattribute20 = gcnew XmlSchemaAttribute(); - myAttributeGroupB->Attributes->Add(someattribute20); - someattribute20->Name = "someattribute20"; - someattribute20->SchemaTypeName = gcnew XmlQualifiedName("date", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAttributeGroupRef^ myAttributeGroupRefA = gcnew XmlSchemaAttributeGroupRef(); - myAttributeGroupB->Attributes->Add(myAttributeGroupRefA); - myAttributeGroupRefA->RefName = gcnew XmlQualifiedName("myAttributeGroupA"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaChoice Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaChoice Example/CPP/source.cpp deleted file mode 100644 index d73de8b2cf6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaChoice Example/CPP/source.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ xeSelected = gcnew XmlSchemaElement(); - xeSelected->Name = "selected"; - schema->Items->Add(xeSelected); - - // - XmlSchemaElement^ xeUnselected = gcnew XmlSchemaElement(); - xeUnselected->Name = "unselected"; - schema->Items->Add(xeUnselected); - - // - XmlSchemaElement^ xeDimpled = gcnew XmlSchemaElement(); - xeDimpled->Name = "dimpled"; - schema->Items->Add(xeDimpled); - - // - XmlSchemaElement^ xePerforated = gcnew XmlSchemaElement(); - xePerforated->Name = "perforated"; - schema->Items->Add(xePerforated); - - // - XmlSchemaComplexType^ chadState = gcnew XmlSchemaComplexType(); - schema->Items->Add(chadState); - chadState->Name = "chadState"; - - // - XmlSchemaChoice^ choice = gcnew XmlSchemaChoice(); - chadState->Particle = choice; - choice->MinOccurs = 1; - choice->MaxOccurs = 1; - - // - XmlSchemaElement^ elementSelected = gcnew XmlSchemaElement(); - choice->Items->Add(elementSelected); - elementSelected->RefName = gcnew XmlQualifiedName("selected"); - - // - XmlSchemaElement^ elementUnselected = gcnew XmlSchemaElement(); - choice->Items->Add(elementUnselected); - elementUnselected->RefName = gcnew XmlQualifiedName("unselected"); - - // - XmlSchemaElement^ elementDimpled = gcnew XmlSchemaElement(); - choice->Items->Add(elementDimpled); - elementDimpled->RefName = gcnew XmlQualifiedName("dimpled"); - - // - XmlSchemaElement^ elementPerforated = gcnew XmlSchemaElement(); - choice->Items->Add(elementPerforated); - elementPerforated->RefName = gcnew XmlQualifiedName("perforated"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/CPP/source.cpp deleted file mode 100644 index b9bf69edc70..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; -using namespace System::Xml::Schema; - -public ref class Class1 -{ - // -public: - void DisplaySchemas( XmlSchemaCollection^ xsc ) - { - XmlSchemaCollectionEnumerator^ ienum = xsc->GetEnumerator(); - while ( ienum->MoveNext() ) - { - XmlSchema^ schema = ienum->Current; - StringWriter^ sw = gcnew StringWriter; - XmlTextWriter^ writer = gcnew XmlTextWriter( sw ); - writer->Formatting = Formatting::Indented; - writer->Indentation = 2; - schema->Write( writer ); - Console::WriteLine( sw ); - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/CPP/source.cpp deleted file mode 100644 index 9dfc421ef93..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::IO; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method( XmlSchemaCollection^ xsc ) - { - // - if ( xsc->Contains( "urn:bookstore-schema" ) ) - { - XmlSchema^ schema = xsc[ "urn:bookstore-schema" ]; - StringWriter^ sw = gcnew StringWriter; - XmlTextWriter^ xmlWriter = gcnew XmlTextWriter( sw ); - xmlWriter->Formatting = Formatting::Indented; - xmlWriter->Indentation = 2; - schema->Write( xmlWriter ); - Console::WriteLine( sw ); - } - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContent Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContent Example/CPP/source.cpp deleted file mode 100644 index 65680c23fba..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContent Example/CPP/source.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaComplexType^ address = gcnew XmlSchemaComplexType(); - schema->Items->Add(address); - address->Name = "address"; - - // - XmlSchemaSequence^ sequence = gcnew XmlSchemaSequence(); - address->Particle = sequence; - - // - XmlSchemaElement^ elementName = gcnew XmlSchemaElement(); - sequence->Items->Add(elementName); - elementName->Name = "name"; - elementName->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementStreet = gcnew XmlSchemaElement(); - sequence->Items->Add(elementStreet); - elementStreet->Name = "street"; - elementStreet->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementCity = gcnew XmlSchemaElement(); - sequence->Items->Add(elementCity); - elementCity->Name = "city"; - elementCity->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaComplexType^ USAddress = gcnew XmlSchemaComplexType(); - schema->Items->Add(USAddress); - USAddress->Name = "USAddress"; - - // - XmlSchemaComplexContent^ complexContent = gcnew XmlSchemaComplexContent(); - USAddress->ContentModel = complexContent; - - // - XmlSchemaComplexContentExtension^ extensionAddress = gcnew XmlSchemaComplexContentExtension(); - complexContent->Content = extensionAddress; - extensionAddress->BaseTypeName = gcnew XmlQualifiedName("address"); - - // - XmlSchemaSequence^ sequence2 = gcnew XmlSchemaSequence(); - extensionAddress->Particle = sequence2; - - // - XmlSchemaElement^ elementUSState = gcnew XmlSchemaElement(); - sequence2->Items->Add(elementUSState); - elementUSState->Name = "state"; - elementUSState->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - - // - XmlSchemaElement^ elementZipcode = gcnew XmlSchemaElement(); - sequence2->Items->Add(elementZipcode); - elementZipcode->Name = "zipcode"; - elementZipcode->SchemaTypeName = gcnew XmlQualifiedName("positiveInteger", "http://www.w3.org/2001/XMLSchema"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContentRestriction Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContentRestriction Example/CPP/source.cpp deleted file mode 100644 index 8c05936319d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContentRestriction Example/CPP/source.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaComplexType^ phoneNumber = gcnew XmlSchemaComplexType(); - phoneNumber->Name = "phoneNumber"; - - // - XmlSchemaSequence^ phoneNumberSequence = gcnew XmlSchemaSequence(); - - // - XmlSchemaElement^ areaCode1 = gcnew XmlSchemaElement(); - areaCode1->MinOccurs = 0; - areaCode1->MaxOccursString = "1"; - areaCode1->Name = "areaCode"; - phoneNumberSequence->Items->Add(areaCode1); - - // - XmlSchemaElement^ prefix1 = gcnew XmlSchemaElement(); - prefix1->MinOccurs = 1; - prefix1->MaxOccursString = "1"; - prefix1->Name = "prefix"; - phoneNumberSequence->Items->Add(prefix1); - - // - XmlSchemaElement^ number1 = gcnew XmlSchemaElement(); - number1->MinOccurs = 1; - number1->MaxOccursString = "1"; - number1->Name = "number"; - phoneNumberSequence->Items->Add(number1); - - phoneNumber->Particle = phoneNumberSequence; - - schema->Items->Add(phoneNumber); - - // - XmlSchemaComplexType^ localPhoneNumber = gcnew XmlSchemaComplexType(); - localPhoneNumber->Name = "localPhoneNumber"; - - // - XmlSchemaComplexContent^ complexContent = gcnew XmlSchemaComplexContent(); - - // - XmlSchemaComplexContentRestriction^ restriction = gcnew XmlSchemaComplexContentRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("phoneNumber", ""); - - // - XmlSchemaSequence^ sequence2 = gcnew XmlSchemaSequence(); - - // - XmlSchemaElement^ areaCode2 = gcnew XmlSchemaElement(); - areaCode2->MinOccurs = 0; - areaCode2->MaxOccursString = "1"; - areaCode2->Name = "areaCode"; - sequence2->Items->Add(areaCode2); - - // - XmlSchemaElement^ prefix2 = gcnew XmlSchemaElement(); - prefix2->MinOccurs = 1; - prefix2->MaxOccursString = "1"; - prefix2->Name = "prefix"; - sequence2->Items->Add(prefix2); - - // - XmlSchemaElement^ number2 = gcnew XmlSchemaElement(); - number2->MinOccurs = 1; - number2->MaxOccursString = "1"; - number2->Name = "number"; - sequence2->Items->Add(number2); - - restriction->Particle = sequence2; - complexContent->Content = restriction; - localPhoneNumber->ContentModel = complexContent; - - schema->Items->Add(localPhoneNumber); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaEnumerationFacet Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaEnumerationFacet Example/CPP/source.cpp deleted file mode 100644 index 6381b6b7526..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaEnumerationFacet Example/CPP/source.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ SizeType = gcnew XmlSchemaSimpleType(); - SizeType->Name = "SizeType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaEnumerationFacet^ enumerationSmall = gcnew XmlSchemaEnumerationFacet(); - enumerationSmall->Value = "Small"; - restriction->Facets->Add(enumerationSmall); - - // - XmlSchemaEnumerationFacet^ enumerationMedium = gcnew XmlSchemaEnumerationFacet(); - enumerationMedium->Value = "Medium"; - restriction->Facets->Add(enumerationMedium); - - // - XmlSchemaEnumerationFacet^ enumerationLarge = gcnew XmlSchemaEnumerationFacet(); - enumerationLarge->Value = "Large"; - restriction->Facets->Add(enumerationLarge); - - SizeType->Content = restriction; - - schema->Items->Add(SizeType); - - // - XmlSchemaElement^ elementItem = gcnew XmlSchemaElement(); - elementItem->Name = "Item"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ attributeSize = gcnew XmlSchemaAttribute(); - attributeSize->Name = "Size"; - attributeSize->SchemaTypeName = gcnew XmlQualifiedName("SizeType", ""); - complexType->Attributes->Add(attributeSize); - - elementItem->SchemaType = complexType; - - schema->Items->Add(elementItem); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaException Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaException Example/CPP/source.cpp deleted file mode 100644 index b7af3eb044a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaException Example/CPP/source.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class ValidXsd -{ -public: - - static void Main() - { - FileStream^ fs; - XmlSchema^ schema; - - try - { - fs = gcnew FileStream("example.xsd", FileMode::Open); - schema = XmlSchema::Read(fs, gcnew ValidationEventHandler(ShowCompileError)); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ShowCompileError); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - schema = compiledSchema; - - if (schema->IsCompiled) - { - // Schema is successfully compiled. - // Do something with it here. - - } - } - catch (XmlSchemaException^ e) - { - Console::WriteLine("LineNumber = {0}", e->LineNumber); - Console::WriteLine("LinePosition = {0}", e->LinePosition); - Console::WriteLine("Message = {0}", e->Message); - } - - } - - static void ShowCompileError(Object^ sender, ValidationEventArgs^ e) - { - Console::WriteLine("Validation Error: {0}", e->Message); - } -}; - -int main() -{ - ValidXsd::Main(); - Console::ReadLine(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaGroup Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaGroup Example/CPP/source.cpp deleted file mode 100644 index 308c590aadf..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaGroup Example/CPP/source.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ elementThing1 = gcnew XmlSchemaElement(); - schema->Items->Add(elementThing1); - elementThing1->Name = "thing1"; - elementThing1->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementThing2 = gcnew XmlSchemaElement(); - schema->Items->Add(elementThing2); - elementThing2->Name = "thing2"; - elementThing2->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementThing3 = gcnew XmlSchemaElement(); - schema->Items->Add(elementThing3); - elementThing3->Name = "thing3"; - elementThing3->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAttribute^ myAttribute = gcnew XmlSchemaAttribute(); - schema->Items->Add(myAttribute); - myAttribute->Name = "myAttribute"; - myAttribute->SchemaTypeName = gcnew XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaGroup^ myGroupOfThings = gcnew XmlSchemaGroup(); - schema->Items->Add(myGroupOfThings); - myGroupOfThings->Name = "myGroupOfThings"; - - // - XmlSchemaSequence^ sequence = gcnew XmlSchemaSequence(); - myGroupOfThings->Particle = sequence; - - // - XmlSchemaElement^ elementThing1Ref = gcnew XmlSchemaElement(); - sequence->Items->Add(elementThing1Ref); - elementThing1Ref->RefName = gcnew XmlQualifiedName("thing1"); - - // - XmlSchemaElement^ elementThing2Ref = gcnew XmlSchemaElement(); - sequence->Items->Add(elementThing2Ref); - elementThing2Ref->RefName = gcnew XmlQualifiedName("thing2"); - - // - XmlSchemaElement^ elementThing3Ref = gcnew XmlSchemaElement(); - sequence->Items->Add(elementThing3Ref); - elementThing3Ref->RefName = gcnew XmlQualifiedName("thing3"); - - // - XmlSchemaComplexType^ myComplexType = gcnew XmlSchemaComplexType(); - schema->Items->Add(myComplexType); - myComplexType->Name = "myComplexType"; - - // - XmlSchemaGroupRef^ myGroupOfThingsRef = gcnew XmlSchemaGroupRef(); - myComplexType->Particle = myGroupOfThingsRef; - myGroupOfThingsRef->RefName = gcnew XmlQualifiedName("myGroupOfThings"); - - // - XmlSchemaAttribute^ myAttributeRef = gcnew XmlSchemaAttribute(); - myComplexType->Attributes->Add(myAttributeRef); - myAttributeRef->RefName = gcnew XmlQualifiedName("myAttribute"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaNotation Example/CPP/notation.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaNotation Example/CPP/notation.cpp deleted file mode 100644 index 4f5ccb60525..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaNotation Example/CPP/notation.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaNotation^ notation = gcnew XmlSchemaNotation(); - notation->Name = "jpeg"; - notation->Public = "image/jpeg"; - notation->System = "viewer.exe"; - - schema->Items->Add(notation); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject Example/CPP/source.cpp deleted file mode 100644 index 320ba3c48fc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject Example/CPP/source.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Reflection; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class ValidXSD -{ -private: - static void DisplayObjects(Object^ o) - { - DisplayObjects(o, ""); - } - - static void DisplayObjects(Object^ o, String^ indent) - { - Console::WriteLine("{0}{1}", indent, o); - - for each (PropertyInfo^ property1 in o->GetType()->GetProperties()) - { - if (property1->PropertyType->FullName == "System.Xml.Schema.XmlSchemaObjectCollection") - { - XmlSchemaObjectCollection^ childObjectCollection = dynamic_cast(property1->GetValue(o, nullptr)); - - for each (XmlSchemaObject^ schemaObject in childObjectCollection) - { - DisplayObjects(schemaObject, indent + "\t"); - } - } - } - } - - static void ShowCompileError(Object^ sender, ValidationEventArgs^ e) - { - Console::WriteLine("Validation Error: {0}", e->Message); - } - -public: - static int Main() - { - String^ xsd = "example.xsd"; - - FileStream^ fs; - XmlSchema^ schema; - try - { - fs = gcnew FileStream(xsd, FileMode::Open); - schema = XmlSchema::Read(fs, gcnew ValidationEventHandler(ShowCompileError)); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ShowCompileError); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - schema = compiledSchema; - - if (schema->IsCompiled) - { - DisplayObjects(schema); - } - return 0; - } - catch (XmlSchemaException^ e) - { - Console::WriteLine("LineNumber = {0}", e->LineNumber); - Console::WriteLine("LinePosition = {0}", e->LinePosition); - Console::WriteLine("Message = {0}", e->Message); - Console::WriteLine("Source = {0}", e->Source); - return -1; - } - } -}; - -int main() -{ - ValidXSD::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/CPP/namespaces.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/CPP/namespaces.cpp deleted file mode 100644 index f4e63a564af..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/CPP/namespaces.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -int main() -{ - XmlSchema^ s = gcnew XmlSchema; - s->TargetNamespace = "myNamespace"; - s->Namespaces->Add( "myImpPrefix", "myImportNamespace" ); - - // Create the element. - XmlSchemaImport^ import = gcnew XmlSchemaImport; - import->Namespace = "myImportNamespace"; - import->SchemaLocation = "http://www.example.com/myImportNamespace"; - s->Includes->Add( import ); - - // Create an element and assign a type from imported schema. - XmlSchemaElement^ elem = gcnew XmlSchemaElement; - elem->SchemaTypeName = gcnew XmlQualifiedName( "importType","myImportNamespace" ); - elem->Name = "element1"; - s->Items->Add( elem ); - s->Write( Console::Out ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/CPP/source.cpp deleted file mode 100644 index 4c7edb2f322..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XMLSchemaExamples -{ - -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ generalPrice = gcnew XmlSchemaElement(); - generalPrice->Name = "generalPrice"; - - // - XmlSchemaComplexType^ ct = gcnew XmlSchemaComplexType(); - - // - XmlSchemaSimpleContent^ simpleContent = gcnew XmlSchemaSimpleContent(); - - // - XmlSchemaSimpleContentExtension^ simpleContent_extension = gcnew XmlSchemaSimpleContentExtension(); - simpleContent_extension->BaseTypeName = gcnew XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAttribute^ currency = gcnew XmlSchemaAttribute(); - currency->Name = "currency"; - currency->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - simpleContent_extension->Attributes->Add(currency); - - simpleContent->Content = simpleContent_extension; - ct->ContentModel = simpleContent; - generalPrice->SchemaType = ct; - - schema->Items->Add(generalPrice); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleType Example/CPP/source.cpp deleted file mode 100644 index 35a881cdd78..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleType Example/CPP/source.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ LotteryNumberType = gcnew XmlSchemaSimpleType(); - LotteryNumberType->Name = "LotteryNumber"; - - // - XmlSchemaSimpleTypeRestriction^ LotteryNumberRestriction = gcnew XmlSchemaSimpleTypeRestriction(); - LotteryNumberRestriction->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMinInclusiveFacet^ minInclusive = gcnew XmlSchemaMinInclusiveFacet(); - minInclusive->Value = "1"; - LotteryNumberRestriction->Facets->Add(minInclusive); - - // - XmlSchemaMaxInclusiveFacet^ maxInclusive = gcnew XmlSchemaMaxInclusiveFacet(); - maxInclusive->Value = "99"; - LotteryNumberRestriction->Facets->Add(maxInclusive); - - LotteryNumberType->Content = LotteryNumberRestriction; - schema->Items->Add(LotteryNumberType); - - // - XmlSchemaSimpleType^ LotteryNumberListType = gcnew XmlSchemaSimpleType(); - LotteryNumberListType->Name = "LotteryNumberList"; - - // - XmlSchemaSimpleTypeList^ list = gcnew XmlSchemaSimpleTypeList(); - list->ItemTypeName = gcnew XmlQualifiedName("LotteryNumber", ""); - LotteryNumberListType->Content = list; - - schema->Items->Add(LotteryNumberListType); - - // - XmlSchemaSimpleType^ LotteryNumbersType = gcnew XmlSchemaSimpleType(); - LotteryNumbersType->Name = "LotteryNumbers"; - - // - XmlSchemaSimpleTypeRestriction^ LotteryNumbersRestriction = gcnew XmlSchemaSimpleTypeRestriction(); - LotteryNumbersRestriction->BaseTypeName = gcnew XmlQualifiedName("LotteryNumberList", ""); - - // - XmlSchemaLengthFacet^ length = gcnew XmlSchemaLengthFacet(); - length->Value = "5"; - LotteryNumbersRestriction->Facets->Add(length); - - LotteryNumbersType->Content = LotteryNumbersRestriction; - - schema->Items->Add(LotteryNumbersType); - - // - XmlSchemaElement^ TodaysLottery = gcnew XmlSchemaElement(); - TodaysLottery->Name = "TodaysLottery"; - TodaysLottery->SchemaTypeName = gcnew XmlQualifiedName("LotteryNumbers", ""); - - schema->Items->Add(TodaysLottery); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSignificantWhitespace.NodeType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSignificantWhitespace.NodeType Example/CPP/source.cpp deleted file mode 100644 index 78ec91dd354..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSignificantWhitespace.NodeType Example/CPP/source.cpp +++ /dev/null @@ -1,119 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -private: - XmlNode^ currNode; - XmlTextReader^ reader; - -public: - Sample() - { - reader = nullptr; - String^ filename = "space.xml"; - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "" - "Eva" - "Corets" - "" ); - Console::WriteLine( "InnerText before..." ); - Console::WriteLine( doc->DocumentElement->InnerText ); - - // Add white space. - currNode = doc->DocumentElement; - XmlSignificantWhitespace^ sigws = doc->CreateSignificantWhitespace( "\t" ); - currNode->InsertAfter( sigws, currNode->FirstChild ); - Console::WriteLine(); - Console::WriteLine( "InnerText after..." ); - Console::WriteLine( doc->DocumentElement->InnerText ); - - // Save and then display the file. - doc->Save( filename ); - Console::WriteLine(); - Console::WriteLine( "Reading file..." ); - ReadFile( filename ); - } - - - // Parse the file and print out each node. - void ReadFile( String^ filename ) - { - try - { - reader = gcnew XmlTextReader( filename ); - String^ sNodeType = nullptr; - while ( reader->Read() ) - { - sNodeType = NodeTypeToString( reader->NodeType ); - - // Print the node type, name, and value. - Console::WriteLine( "{0}<{1}> {2}", sNodeType, reader->Name, reader->Value ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - - } - - static String^ NodeTypeToString( XmlNodeType nodetype ) - { - String^ sNodeType = nullptr; - switch ( nodetype ) - { - case XmlNodeType::None: - sNodeType = "None"; - break; - - case XmlNodeType::Element: - sNodeType = "Element"; - break; - - case XmlNodeType::Attribute: - sNodeType = "Attribute"; - break; - - case XmlNodeType::Text: - sNodeType = "Text"; - break; - - case XmlNodeType::Comment: - sNodeType = "Comment"; - break; - - case XmlNodeType::Document: - sNodeType = "Document"; - break; - - case XmlNodeType::Whitespace: - sNodeType = "Whitespace"; - break; - - case XmlNodeType::SignificantWhitespace: - sNodeType = "SignificantWhitespace"; - break; - - case XmlNodeType::EndElement: - sNodeType = "EndElement"; - break; - } - return sNodeType; - } - -}; - -int main() -{ - gcnew Sample; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.BaseURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.BaseURI Example/CPP/source.cpp deleted file mode 100644 index 47a0236b987..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.BaseURI Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - //Load the reader with the XML file. - reader = gcnew XmlTextReader( "http://localhost/baseuri.xml" ); - - //Parse the file and display the base URI for each node. - while ( reader->Read() ) - { - Console::WriteLine( "({0}) {1}", reader->NodeType, reader->BaseURI ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetAttribute1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetAttribute1 Example/CPP/source.cpp deleted file mode 100644 index e63d63dc208..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - //Load the reader with the XML file. - reader = gcnew XmlTextReader( "attrs.xml" ); - - //Read the ISBN attribute. - reader->MoveToContent(); - String^ isbn = reader->GetAttribute( "ISBN" ); - Console::WriteLine( "The ISBN value: {0}", isbn ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetRemainder Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetRemainder Example/CPP/source.cpp deleted file mode 100644 index f61a0885d7c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetRemainder Example/CPP/source.cpp +++ /dev/null @@ -1,82 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - String^ filename = "tworeads.xml"; - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Read the first part of the XML document - while ( reader->Read() ) - { - - // Display the elements and stop reading on the book endelement tag - // then go to ReadPart2 to start another reader to read the rest of the file. - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::WriteLine( "Name: {0}", reader->Name ); - break; - - case XmlNodeType::Text: - Console::WriteLine( " Element Text: {0}", reader->Value ); - break; - - case XmlNodeType::EndElement: - - // Stop reading when the reader gets to the end element of the book node. - if ( "book" == reader->LocalName ) - { - Console::WriteLine( "End reading first book..." ); - Console::WriteLine(); - goto ReadPart2; - } - break; - } - } - - - // Read the rest of the XML document - -ReadPart2: - Console::WriteLine( "Begin reading second book..." ); - - // Create a new reader to read the rest of the document. - XmlTextReader^ reader2 = gcnew XmlTextReader( reader->GetRemainder() ); - while ( reader2->Read() ) - { - switch ( reader2->NodeType ) - { - case XmlNodeType::Element: - Console::WriteLine( "Name: {0}", reader2->Name ); - break; - - case XmlNodeType::Text: - Console::WriteLine( " Element Text: {0}", reader2->Value ); - break; - - case XmlNodeType::EndElement: - - // Stop reading when the reader gets to the end element of the book node. - if ( "book" == reader2->LocalName ) - { - Console::WriteLine( "End reading second book..." ); - goto Done; - } - break; - } - } - - -Done: - Console::WriteLine( "Done." ); - reader->Close(); - reader2->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.HasValue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.HasValue Example/CPP/source.cpp deleted file mode 100644 index 96ecc78d7af..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.HasValue Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - //Load the reader with the XML file. - reader = gcnew XmlTextReader( "book1.xml" ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - //Parse the file and display each node. - while ( reader->Read() ) - { - if ( reader->HasValue ) - Console::WriteLine( "({0}) {1}={2}", reader->NodeType, reader->Name, reader->Value ); - else - Console::WriteLine( "({0}) {1}", reader->NodeType, reader->Name ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp deleted file mode 100644 index a5d564f75ff..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - // Load the reader with the XML file. - reader = gcnew XmlTextReader( "book2.xml" ); - - // Parse the file. If they exist, display the prefix and - // namespace URI of each node. - while ( reader->Read() ) - { - if ( reader->IsStartElement() ) - { - if ( reader->Prefix == String::Empty ) - Console::WriteLine( "<{0}>", reader->LocalName ); - else - { - Console::Write( "<{0}:{1}>", reader->Prefix, reader->LocalName ); - Console::WriteLine( " The namespace URI is {0}", reader->NamespaceURI ); - } - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp deleted file mode 100644 index 21a005822c1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; - -public ref class Class1 -{ - // -public: - void DisplayAttributes( XmlReader^ reader ) - { - if ( reader->HasAttributes ) - { - Console::WriteLine( "Attributes of <{0}>", reader->Name ); - for ( int i = 0; i < reader->AttributeCount; i++ ) - { - reader->MoveToAttribute( i ); - Console::Write( " {0}={1}", reader->Name, reader->Value ); - - } - reader->MoveToElement(); //Moves the reader back to the element node. - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToFirstAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToFirstAttribute Example/CPP/source.cpp deleted file mode 100644 index b5a9bd22ca6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToFirstAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - //Load the reader with the XML file. - reader = gcnew XmlTextReader( "attrs.xml" ); - - //Read the genre attribute. - reader->MoveToContent(); - reader->MoveToFirstAttribute(); - String^ genre = reader->Value; - Console::WriteLine( "The genre value: {0}", genre ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp deleted file mode 100644 index e6fe1c8a26a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp +++ /dev/null @@ -1,74 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - String^ filename = "items.xml"; - try - { - - // Load the reader with the data file and ignore all white space nodes. - reader = gcnew XmlTextReader( filename ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Parse the file and display each of the nodes. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( "<{0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( reader->Value ); - break; - - case XmlNodeType::CDATA: - Console::Write( "", reader->Value ); - break; - - case XmlNodeType::ProcessingInstruction: - Console::Write( "", reader->Name, reader->Value ); - break; - - case XmlNodeType::Comment: - Console::Write( "", reader->Value ); - break; - - case XmlNodeType::XmlDeclaration: - Console::Write( "" ); - break; - - case XmlNodeType::Document: - break; - - case XmlNodeType::DocumentType: - Console::Write( "Name, reader->Value ); - break; - - case XmlNodeType::EntityReference: - Console::Write( reader->Name ); - break; - - case XmlNodeType::EndElement: - Console::Write( "", reader->Name ); - break; - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/CPP/source.cpp deleted file mode 100644 index e47fe405c6d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - String^ filename = "binary.xml"; - try - { - reader = gcnew XmlTextReader( filename ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Read the file. Stop at the Base64 element. - while ( reader->Read() ) - { - if ( "Base64" == reader->Name ) - break; - } - - // Read the Base64 data. Write the decoded - // bytes to the console. - Console::WriteLine( "Reading Base64... " ); - int base64len = 0; - array^base64 = gcnew array(1000); - do - { - base64len = reader->ReadBase64( base64, 0, 50 ); - for ( int i = 0; i < base64len; i++ ) - Console::Write( base64[ i ] ); - } - while ( reader->Name->Equals( "Base64" ) ); - - // Read the BinHex data. Write the decoded - // bytes to the console. - Console::WriteLine( "\r\nReading BinHex..." ); - int binhexlen = 0; - array^binhex = gcnew array(1000); - do - { - binhexlen = reader->ReadBinHex( binhex, 0, 50 ); - for ( int i = 0; i < binhexlen; i++ ) - Console::Write( binhex[ i ] ); - } - while ( reader->Name->Equals( "BinHex" ) ); - } - finally - { - Console::WriteLine(); - Console::WriteLine( "Processing of the file {0} complete.", filename ); - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadChars Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadChars Example/CPP/source.cpp deleted file mode 100644 index f4197a14142..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadChars Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; - -// Reads an XML document using ReadChars -int main() -{ - XmlTextReader^ reader = nullptr; - String^ filename = "items.xml"; - try - { - - // Declare variables used by ReadChars - array^buffer; - int iCnt = 0; - int charbuffersize; - - // Load the reader with the data file. Ignore white space. - reader = gcnew XmlTextReader( filename ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Set variables used by ReadChars. - charbuffersize = 10; - buffer = gcnew array(charbuffersize); - - // Parse the file. Read the element content - // using the ReadChars method. - reader->MoveToContent(); - while ( (iCnt = reader->ReadChars( buffer, 0, charbuffersize )) > 0 ) - { - - // Print out chars read and the buffer contents. - Console::WriteLine( " Chars read to buffer:{0}", iCnt ); - Console::WriteLine( " Buffer: [{0}]", gcnew String( buffer,0,iCnt ) ); - - // Clear the buffer. - Array::Clear( buffer, 0, charbuffersize ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.WhitespaceHandling Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.WhitespaceHandling Example/CPP/source.cpp deleted file mode 100644 index f64733ec447..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.WhitespaceHandling Example/CPP/source.cpp +++ /dev/null @@ -1,69 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -void ReadXML( XmlParserContext^ context, String^ xmlFrag, WhitespaceHandling ws ) -{ - - //Create the reader and specify the WhitespaceHandling setting. - XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - reader->WhitespaceHandling = ws; - - //Parse the XML and display each of the nodes. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::WriteLine( "{0}: <{1}>", reader->NodeType, reader->Name ); - break; - - case XmlNodeType::Text: - Console::WriteLine( "{0}: {1}", reader->NodeType, reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::WriteLine( "{0}: ", reader->NodeType, reader->Name ); - break; - - case XmlNodeType::Whitespace: - Console::WriteLine( "{0}:", reader->NodeType ); - break; - - case XmlNodeType::SignificantWhitespace: - Console::WriteLine( "{0}:", reader->NodeType ); - break; - } - } - - - //Close the reader. - reader->Close(); -} - -int main() -{ - - //Create the XML fragment to be parsed. - String^ xmlFrag = " " - " Pride And Prejudice" - " novel" - ""; - - //Create the XmlNamespaceManager. - NameTable^ nt = gcnew NameTable; - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt ); - - //Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::Default ); - Console::WriteLine( "Read the XML and ignore all white space..." ); - ReadXML( context, xmlFrag, WhitespaceHandling::None ); - Console::WriteLine( "\r\nRead the XML including white space nodes..." ); - ReadXML( context, xmlFrag, WhitespaceHandling::All ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp deleted file mode 100644 index fb1cc689964..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create a writer to write XML to the console. - XmlTextWriter^ writer = nullptr; - writer = gcnew XmlTextWriter( Console::Out ); - - //Use indentation for readability. - writer->Formatting = Formatting::Indented; - writer->Indentation = 4; - - //Write an element (this one is the root). - writer->WriteStartElement( "book" ); - - //Write the title element. - writer->WriteStartElement( "title" ); - writer->WriteString( "Pride And Prejudice" ); - writer->WriteEndElement(); - - //Write the close tag for the root element. - writer->WriteEndElement(); - - //Write the XML to file and close the writer. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteEndElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteEndElement Example/CPP/source.cpp deleted file mode 100644 index f9eaffb0162..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteEndElement Example/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = nullptr; - String^ filename = "sampledata.xml"; - writer = gcnew XmlTextWriter( filename, nullptr ); - - //Use indenting for readability. - writer->Formatting = Formatting::Indented; - - //Write the XML delcaration - writer->WriteStartDocument(); - - //Write the ProcessingInstruction node. - String^ PItext = "type=\"text/xsl\" href=\"book.xsl\""; - writer->WriteProcessingInstruction( "xml-stylesheet", PItext ); - - //Write the DocumentType node. - writer->WriteDocType( "book", nullptr, nullptr, "" ); - - //Write a Comment node. - writer->WriteComment( "sample XML" ); - - //Write the root element. - writer->WriteStartElement( "book" ); - - //Write the genre attribute. - writer->WriteAttributeString( "genre", "novel" ); - - //Write the ISBN attribute. - writer->WriteAttributeString( "ISBN", "1-8630-014" ); - - //Write the title. - writer->WriteElementString( "title", "The Handmaid's Tale" ); - - //Write the style element. - writer->WriteStartElement( "style" ); - writer->WriteEntityRef( "h" ); - writer->WriteEndElement(); - - //Write the price. - writer->WriteElementString( "price", "19.95" ); - - //Write CDATA. - writer->WriteCData( "Prices 15% off!!" ); - - //Write the close tag for the root element. - writer->WriteEndElement(); - writer->WriteEndDocument(); - - //Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); - - //Load the file into an XmlDocument to ensure well formed XML. - XmlDocument^ doc = gcnew XmlDocument; - - //Preserve white space for readability. - doc->PreserveWhitespace = true; - - //Load the file. - doc->Load( filename ); - - //Display the XML content to the console. - Console::Write( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteFullEndElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteFullEndElement Example/CPP/source.cpp deleted file mode 100644 index 51d524810dc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteFullEndElement Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create a writer to write XML to the console. - XmlTextWriter^ writer = nullptr; - writer = gcnew XmlTextWriter( Console::Out ); - - //Use indentation for readability. - writer->Formatting = Formatting::Indented; - - //Write an element (this one is the root). - writer->WriteStartElement( "order" ); - - //Write some attributes. - writer->WriteAttributeString( "date", "2/19/01" ); - writer->WriteAttributeString( "orderID", "136A5" ); - - //Write a full end element. Because this element has no - //content, calling WriteEndElement would have written a - //short end tag '/>'. - writer->WriteFullEndElement(); - - //Write the XML to file and close the writer - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteQualifiedName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteQualifiedName Example/CPP/source.cpp deleted file mode 100644 index 2adeaa8ff54..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteQualifiedName Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = nullptr; - String^ filename = "sampledata.xml"; - writer = gcnew XmlTextWriter( filename, nullptr ); - - // Use indenting for readability. - writer->Formatting = Formatting::Indented; - - // Write the root element. - writer->WriteStartElement( "schema" ); - - // Write the namespace declarations. - writer->WriteAttributeString( "xmlns", nullptr, "http://www.w3.org/2001/XMLSchema" ); - writer->WriteAttributeString( "xmlns", "po", nullptr, "http://contoso.com/po" ); - writer->WriteStartElement( "element" ); - writer->WriteAttributeString( "name", "purchaseOrder" ); - - // Write the type attribute. - writer->WriteStartAttribute( nullptr, "type", nullptr ); - writer->WriteQualifiedName( "PurchaseOrder", "http://contoso.com/po" ); - writer->WriteEndAttribute(); - writer->WriteEndElement(); - - // Write the close tag for the root element. - writer->WriteEndElement(); - - // Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); - - // Read the file back in and parse to ensure well formed XML. - XmlDocument^ doc = gcnew XmlDocument; - - // Preserve white space for readability. - doc->PreserveWhitespace = true; - - // Load the file. - doc->Load( filename ); - - // Write the XML content to the console. - Console::Write( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteRaw1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteRaw1 Example/CPP/source.cpp deleted file mode 100644 index 147d3385162..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteRaw1 Example/CPP/source.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create a writer that outputs to the console. - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - - // Write the root element. - writer->WriteStartElement( "Items" ); - - // Write a string using WriteRaw. Note that the special - // characters are not escaped. - writer->WriteStartElement( "Item" ); - writer->WriteString( "Write unescaped text: " ); - writer->WriteRaw( "this & that" ); - writer->WriteEndElement(); - - // Write the same string using WriteString. Note that the - // special characters are escaped. - writer->WriteStartElement( "Item" ); - writer->WriteString( "Write the same string using WriteString: " ); - writer->WriteString( "this & that" ); - writer->WriteEndElement(); - - // Write the close tag for the root element. - writer->WriteEndElement(); - - // Write the XML to file and close the writer. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp deleted file mode 100644 index 7ebefe6b4d0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = nullptr; - String^ filename = "sampledata.xml"; - writer = gcnew XmlTextWriter( filename, nullptr ); - - //Use indenting for readability. - writer->Formatting = Formatting::Indented; - - //Write the XML delcaration. - writer->WriteStartDocument(); - - //Write the ProcessingInstruction node. - String^ PItext = "type='text/xsl' href='book.xsl'"; - writer->WriteProcessingInstruction( "xml-stylesheet", PItext ); - - //Write the DocumentType node. - writer->WriteDocType( "book", nullptr, nullptr, "" ); - - //Write a Comment node. - writer->WriteComment( "sample XML" ); - - //Write a root element. - writer->WriteStartElement( "book" ); - - //Write the genre attribute. - writer->WriteAttributeString( "genre", "novel" ); - - //Write the ISBN attribute. - writer->WriteAttributeString( "ISBN", "1-8630-014" ); - - //Write the title. - writer->WriteElementString( "title", "The Handmaid's Tale" ); - - //Write the style element. - writer->WriteStartElement( "style" ); - writer->WriteEntityRef( "h" ); - writer->WriteEndElement(); - - //Write the price. - writer->WriteElementString( "price", "19.95" ); - - //Write CDATA. - writer->WriteCData( "Prices 15% off!!" ); - - //Write the close tag for the root element. - writer->WriteEndElement(); - writer->WriteEndDocument(); - - //Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); - - //Load the file into an XmlDocument to ensure well formed XML. - XmlDocument^ doc = gcnew XmlDocument; - - //Preserve white space for readability. - doc->PreserveWhitespace = true; - - //Load the file. - doc->Load( filename ); - - //Display the XML content to the console. - Console::Write( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp deleted file mode 100644 index d18c68662b6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - String^ filename = "sampledata.xml"; - XmlTextWriter^ writer = gcnew XmlTextWriter( filename, nullptr ); - - //Use indenting for readability. - writer->Formatting = Formatting::Indented; - writer->WriteComment( "sample XML fragment" ); - - //Write an element (this one is the root). - writer->WriteStartElement( "bookstore" ); - - //Write the namespace declaration. - writer->WriteAttributeString( "xmlns", "bk", nullptr, "urn:samples" ); - writer->WriteStartElement( "book" ); - - //Lookup the prefix and then write the ISBN attribute. - String^ prefix = writer->LookupPrefix( "urn:samples" ); - writer->WriteStartAttribute( prefix, "ISBN", "urn:samples" ); - writer->WriteString( "1-861003-78" ); - writer->WriteEndAttribute(); - - //Write the title. - writer->WriteStartElement( "title" ); - writer->WriteString( "The Handmaid's Tale" ); - writer->WriteEndElement(); - - //Write the price. - writer->WriteElementString( "price", "19.95" ); - - //Write the style element. - writer->WriteStartElement( prefix, "style", "urn:samples" ); - writer->WriteString( "hardcover" ); - writer->WriteEndElement(); - - //Write the end tag for the book element. - writer->WriteEndElement(); - - //Write the close tag for the root element. - writer->WriteEndElement(); - - //Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); - - //Read the file back in and parse to ensure well formed XML. - XmlDocument^ doc = gcnew XmlDocument; - - //Preserve white space for readability. - doc->PreserveWhitespace = true; - - //Load the file - doc->Load( filename ); - - //Write the XML content to the console. - Console::Write( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteTimeSpan Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteTimeSpan Example/CPP/source.cpp deleted file mode 100644 index ef94526fc30..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteTimeSpan Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = nullptr; - try - { - writer = gcnew XmlTextWriter( Console::Out ); - - // Write an element. - writer->WriteStartElement( "address" ); - - // Write an email address using entities - // for the @ and . characters. - writer->WriteString( "someone" ); - writer->WriteCharEntity( '@' ); - writer->WriteString( "example" ); - writer->WriteCharEntity( '.' ); - writer->WriteString( "com" ); - writer->WriteEndElement(); - } - finally - { - - // Close the writer. - if ( writer != nullptr ) - writer->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/CPP/source.cpp deleted file mode 100644 index e5fd8acae1e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the writer. - XmlTextWriter^ writer = nullptr; - writer = gcnew XmlTextWriter( "ws.html", nullptr ); - - // Write an element (this one is the root). - writer->WriteStartElement( "p" ); - - // Write the xml:space attribute. - writer->WriteAttributeString( "xml", "space", nullptr, "preserve" ); - - // Verify that xml:space is set properly. - if ( writer->XmlSpace == XmlSpace::Preserve ) - Console::WriteLine( "xmlspace is correct!" ); - - - // Write out the HTML elements. Insert white space - // between 'something' and 'Big' - writer->WriteString( "something" ); - writer->WriteWhitespace( " " ); - writer->WriteElementString( "b", "B" ); - writer->WriteString( "ig" ); - - // Write the root end element. - writer->WriteEndElement(); - - // Write the XML to file and close the writer. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/CPP/source.cpp deleted file mode 100644 index be6e39b350c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - Uri^ baseUri = gcnew Uri( "http://servername/tmp/test.xsl" ); - Uri^ fulluri = resolver->ResolveUri( baseUri, "includefile.xsl" ); - - // Get a stream object containing the XSL file - Stream^ s = dynamic_cast(resolver->GetEntity( fulluri, nullptr, Stream::typeid )); - - // Read the stream object displaying the contents of the XSL file - XmlTextReader^ reader = gcnew XmlTextReader( s ); - while ( reader->Read() ) - { - Console::WriteLine( reader->ReadOuterXml() ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlWhitespace.NodeType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlWhitespace.NodeType Example/CPP/source.cpp deleted file mode 100644 index 15790751077..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlWhitespace.NodeType Example/CPP/source.cpp +++ /dev/null @@ -1,117 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -private: - XmlNode^ currNode; - XmlTextReader^ reader; - -public: - Sample() - { - String^ filename = "space.xml"; - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Eva" - "Corets" - "" ); - Console::WriteLine( "InnerText before..." ); - Console::WriteLine( doc->DocumentElement->InnerText ); - - // Add white space. - currNode = doc->DocumentElement; - XmlWhitespace^ ws = doc->CreateWhitespace( "\r\n" ); - currNode->InsertAfter( ws, currNode->FirstChild ); - Console::WriteLine(); - Console::WriteLine( "InnerText after..." ); - Console::WriteLine( doc->DocumentElement->InnerText ); - - // Save and then display the file. - doc->Save( filename ); - Console::WriteLine(); - Console::WriteLine( "Reading file..." ); - ReadFile( filename ); - } - - - // Parse the file and display each node. - void ReadFile( String^ filename ) - { - try - { - reader = gcnew XmlTextReader( filename ); - String^ sNodeType = nullptr; - while ( reader->Read() ) - { - sNodeType = NodeTypeToString( reader->NodeType ); - - // Print the node type, name, and value. - Console::WriteLine( "{0}<{1}> {2}", sNodeType, reader->Name, reader->Value ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - - } - - static String^ NodeTypeToString( XmlNodeType nodetype ) - { - String^ sNodeType = nullptr; - switch ( nodetype ) - { - case XmlNodeType::None: - sNodeType = "None"; - break; - - case XmlNodeType::Element: - sNodeType = "Element"; - break; - - case XmlNodeType::Attribute: - sNodeType = "Attribute"; - break; - - case XmlNodeType::Text: - sNodeType = "Text"; - break; - - case XmlNodeType::Comment: - sNodeType = "Comment"; - break; - - case XmlNodeType::Document: - sNodeType = "Document"; - break; - - case XmlNodeType::Whitespace: - sNodeType = "Whitespace"; - break; - - case XmlNodeType::SignificantWhitespace: - sNodeType = "SignificantWhitespace"; - break; - - case XmlNodeType::EndElement: - sNodeType = "EndElement"; - break; - } - return sNodeType; - } - -}; - -int main() -{ - gcnew Sample; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/CPP/source.cpp deleted file mode 100644 index fed23d6f782..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; - -int main() -{ - String^ filename = "books.xml"; - String^ stylesheet = "output.xsl"; - - //Load the stylesheet. - XslTransform^ xslt = gcnew XslTransform; - xslt->Load( stylesheet ); - - //Load the file to transform. - XPathDocument^ doc = gcnew XPathDocument( filename ); - - //Create an XmlTextWriter which outputs to the console. - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - - //Transform the file and send the output to the console. - xslt->Transform(doc,nullptr,writer,nullptr); - writer->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaComplexType Example/CPP/complextype.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaComplexType Example/CPP/complextype.cpp deleted file mode 100644 index 3c119776397..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaComplexType Example/CPP/complextype.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - schema->Items->Add(element); - element->Name = "stringElementWithAnyAttribute"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - element->SchemaType = complexType; - - // - XmlSchemaSimpleContent^ simpleContent = gcnew XmlSchemaSimpleContent(); - complexType->ContentModel = simpleContent; - - // - XmlSchemaSimpleContentExtension^ extension = gcnew XmlSchemaSimpleContentExtension(); - simpleContent->Content = extension; - extension->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAnyAttribute^ anyAttribute = gcnew XmlSchemaAnyAttribute(); - extension->AnyAttribute = anyAttribute; - anyAttribute->Namespace = "##targetNamespace"; - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/CPP/datatype.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/CPP/datatype.cpp deleted file mode 100644 index 92d06d54db3..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/CPP/datatype.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlTextReader^ xtr = gcnew XmlTextReader("example.xsd"); - XmlSchema^ schema = XmlSchema::Read(xtr, gcnew ValidationEventHandler(ValidationCallbackOne)); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - for each (XmlSchemaObject^ schemaObject in compiledSchema->Items) - { - if (schemaObject->GetType() == XmlSchemaSimpleType::typeid) - { - XmlSchemaSimpleType^ simpleType = dynamic_cast(schemaObject); - Console::WriteLine("{0} {1}", simpleType->Name, simpleType->Datatype->ValueType); - } - if (schemaObject->GetType() == XmlSchemaComplexType::typeid) - { - XmlSchemaComplexType^ complexType = dynamic_cast(schemaObject); - Console::WriteLine("{0} {1}", complexType->Name, complexType->Datatype->ValueType); - } - } - xtr->Close(); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDocumentation Example/CPP/documentation.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDocumentation Example/CPP/documentation.cpp deleted file mode 100644 index 78ca73c17ae..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDocumentation Example/CPP/documentation.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ simpleType = gcnew XmlSchemaSimpleType(); - simpleType->Name = "northwestStates"; - schema->Items->Add(simpleType); - - // - XmlSchemaAnnotation^ annNorthwestStates = gcnew XmlSchemaAnnotation(); - simpleType->Annotation = annNorthwestStates; - - // States in the Pacific Northwest of US - XmlSchemaDocumentation^ docNorthwestStates = gcnew XmlSchemaDocumentation(); - annNorthwestStates->Items->Add(docNorthwestStates); - docNorthwestStates->Markup = TextToNodeArray("States in the Pacific Northwest of US"); - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - simpleType->Content = restriction; - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaEnumerationFacet^ enumerationWA = gcnew XmlSchemaEnumerationFacet(); - restriction->Facets->Add(enumerationWA); - enumerationWA->Value = "WA"; - - // - XmlSchemaAnnotation^ annWA = gcnew XmlSchemaAnnotation(); - enumerationWA->Annotation = annWA; - - // Washington - XmlSchemaDocumentation^ docWA = gcnew XmlSchemaDocumentation(); - annWA->Items->Add(docWA); - docWA->Markup = TextToNodeArray("Washington"); - - // - XmlSchemaEnumerationFacet^ enumerationOR = gcnew XmlSchemaEnumerationFacet(); - restriction->Facets->Add(enumerationOR); - enumerationOR->Value = "OR"; - - // - XmlSchemaAnnotation^ annOR = gcnew XmlSchemaAnnotation(); - enumerationOR->Annotation = annOR; - - // Oregon - XmlSchemaDocumentation^ docOR = gcnew XmlSchemaDocumentation(); - annOR->Items->Add(docOR); - docOR->Markup = TextToNodeArray("Oregon"); - - // - XmlSchemaEnumerationFacet^ enumerationID = gcnew XmlSchemaEnumerationFacet(); - restriction->Facets->Add(enumerationID); - enumerationID->Value = "ID"; - - // - XmlSchemaAnnotation^ annID = gcnew XmlSchemaAnnotation(); - enumerationID->Annotation = annID; - - // Idaho - XmlSchemaDocumentation^ docID = gcnew XmlSchemaDocumentation(); - annID->Items->Add(docID); - docID->Markup = TextToNodeArray("Idaho"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - - static array^ TextToNodeArray(String^ text) - { - XmlDocument^ doc = gcnew XmlDocument(); - array^ nodes = gcnew array {doc->CreateTextNode(text)}; - return nodes; - } - -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/CPP/element.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/CPP/element.cpp deleted file mode 100644 index cb71c94ba29..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/CPP/element.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ elementCat = gcnew XmlSchemaElement(); - schema->Items->Add(elementCat); - elementCat->Name = "cat"; - elementCat->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementDog); - elementDog->Name = "dog"; - elementDog->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementRedDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementRedDog); - elementRedDog->Name = "redDog"; - elementRedDog->SubstitutionGroup = gcnew XmlQualifiedName("dog"); - - // - XmlSchemaElement^ elementBrownDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementBrownDog); - elementBrownDog->Name = "brownDog"; - elementBrownDog->SubstitutionGroup = gcnew XmlQualifiedName("dog"); - - // - XmlSchemaElement^ elementPets = gcnew XmlSchemaElement(); - schema->Items->Add(elementPets); - elementPets->Name = "pets"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - elementPets->SchemaType = complexType; - - // - XmlSchemaChoice^ choice = gcnew XmlSchemaChoice(); - complexType->Particle = choice; - choice->MinOccurs = 0; - choice->MaxOccursString = "unbounded"; - - // - XmlSchemaElement^ catRef = gcnew XmlSchemaElement(); - choice->Items->Add(catRef); - catRef->RefName = gcnew XmlQualifiedName("cat"); - - // - XmlSchemaElement^ dogRef = gcnew XmlSchemaElement(); - choice->Items->Add(dogRef); - dogRef->RefName = gcnew XmlQualifiedName("dog"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaFractionDigitsFacet Example/CPP/fractiondigitsfacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaFractionDigitsFacet Example/CPP/fractiondigitsfacet.cpp deleted file mode 100644 index acf2f9e018f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaFractionDigitsFacet Example/CPP/fractiondigitsfacet.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ RatingType = gcnew XmlSchemaSimpleType(); - RatingType->Name = "RatingType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaTotalDigitsFacet^ totalDigits = gcnew XmlSchemaTotalDigitsFacet(); - totalDigits->Value = "2"; - restriction->Facets->Add(totalDigits); - - // - XmlSchemaFractionDigitsFacet^ fractionDigits = gcnew XmlSchemaFractionDigitsFacet(); - fractionDigits->Value = "1"; - restriction->Facets->Add(fractionDigits); - - RatingType->Content = restriction; - - schema->Items->Add(RatingType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "movie"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ ratingAttribute = gcnew XmlSchemaAttribute(); - ratingAttribute->Name = "rating"; - ratingAttribute->SchemaTypeName = gcnew XmlQualifiedName("RatingType", ""); - complexType->Attributes->Add(ratingAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaInclude Example/CPP/import_include_sample.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaInclude Example/CPP/import_include_sample.cpp deleted file mode 100644 index 777c38d292a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaInclude Example/CPP/import_include_sample.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class ImportIncludeSample -{ -private: - static void ValidationCallBack(Object^ sender, ValidationEventArgs^ args) - { - - if (args->Severity == XmlSeverityType::Warning) - Console::Write("WARNING: "); - else if (args->Severity == XmlSeverityType::Error) - Console::Write("ERROR: "); - - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - schema->ElementFormDefault = XmlSchemaForm::Qualified; - schema->TargetNamespace = "http://www.w3.org/2001/05/XMLInfoset"; - - // - XmlSchemaImport^ import = gcnew XmlSchemaImport(); - import->Namespace = "http://www.example.com/IPO"; - schema->Includes->Add(import); - - // - XmlSchemaInclude^ include = gcnew XmlSchemaInclude(); - include->SchemaLocation = "example.xsd"; - schema->Includes->Add(include); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallBack); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - -}; - -int main() -{ - ImportIncludeSample::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaKeyRef Example/CPP/key_sample.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaKeyRef Example/CPP/key_sample.cpp deleted file mode 100644 index 89d0bf0c37b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaKeyRef Example/CPP/key_sample.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Xml::Schema; -public ref class XmlSchemaObjectGenerator -{ -private: - static void ValidationCallback( Object^ /*sender*/, ValidationEventArgs^ args ) - { - if ( args->Severity == XmlSeverityType::Warning ) - Console::Write( "WARNING: " ); - else - if ( args->Severity == XmlSeverityType::Error ) - Console::Write( "ERROR: " ); - - Console::WriteLine( args->Message ); - } - - // XmlSchemaObjectGenerator - int main() - { - XmlTextReader^ tr = gcnew XmlTextReader( "empty.xsd" ); - XmlSchema^ schema = XmlSchema::Read( tr, gcnew ValidationEventHandler( XmlSchemaObjectGenerator::ValidationCallback ) ); - schema->ElementFormDefault = XmlSchemaForm::Qualified; - schema->TargetNamespace = "http://www.example.com/Report"; - { - XmlSchemaElement^ element = gcnew XmlSchemaElement; - element->Name = "purchaseReport"; - XmlSchemaComplexType^ element_complexType = gcnew XmlSchemaComplexType; - XmlSchemaSequence^ element_complexType_sequence = gcnew XmlSchemaSequence; - { - XmlSchemaElement^ element_complexType_sequence_element = gcnew XmlSchemaElement; - element_complexType_sequence_element->Name = "region"; - element_complexType_sequence_element->SchemaTypeName = gcnew XmlQualifiedName( "String*","http://www.w3.org/2001/XMLSchema" ); - { - XmlSchemaKeyref^ element_complexType_sequence_element_keyref = gcnew XmlSchemaKeyref; - element_complexType_sequence_element_keyref->Name = "dummy2"; - element_complexType_sequence_element_keyref->Selector = gcnew XmlSchemaXPath; - element_complexType_sequence_element_keyref->Selector->XPath = "r:zip/r:part"; - { - XmlSchemaXPath^ field = gcnew XmlSchemaXPath; - field->XPath = "@number"; - element_complexType_sequence_element_keyref->Fields->Add( field ); - } - element_complexType_sequence_element_keyref->Refer = gcnew XmlQualifiedName( "pNumKey","http://www.example.com/Report" ); - element_complexType_sequence_element->Constraints->Add( element_complexType_sequence_element_keyref ); - } - element_complexType_sequence->Items->Add( element_complexType_sequence_element ); - } - element_complexType->Particle = element_complexType_sequence; - { - XmlSchemaAttribute^ element_complexType_attribute = gcnew XmlSchemaAttribute; - element_complexType_attribute->Name = "periodEnding"; - element_complexType_attribute->SchemaTypeName = gcnew XmlQualifiedName( "date","http://www.w3.org/2001/XMLSchema" ); - element_complexType->Attributes->Add( element_complexType_attribute ); - } - element->SchemaType = element_complexType; - { - XmlSchemaKey^ element_key = gcnew XmlSchemaKey; - element_key->Name = "pNumKey"; - element_key->Selector = gcnew XmlSchemaXPath; - element_key->Selector->XPath = "r:parts/r:part"; - { - XmlSchemaXPath^ field = gcnew XmlSchemaXPath; - field->XPath = "@number"; - element_key->Fields->Add( field ); - } - element->Constraints->Add( element_key ); - } - schema->Items->Add( element ); - } - schema->Write( Console::Out ); - - return 0; - } // main -}; -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaLengthFacet Example/CPP/lengthfacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaLengthFacet Example/CPP/lengthfacet.cpp deleted file mode 100644 index 47765242264..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaLengthFacet Example/CPP/lengthfacet.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ ZipCodeType = gcnew XmlSchemaSimpleType(); - ZipCodeType->Name = "ZipCodeType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaLengthFacet^ length = gcnew XmlSchemaLengthFacet(); - length->Value = "5"; - restriction->Facets->Add(length); - - ZipCodeType->Content = restriction; - - schema->Items->Add(ZipCodeType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Address"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ ZipCodeAttribute = gcnew XmlSchemaAttribute(); - ZipCodeAttribute->Name = "ZipCode"; - ZipCodeAttribute->SchemaTypeName = gcnew XmlQualifiedName("ZipCodeType", ""); - complexType->Attributes->Add(ZipCodeAttribute); - - element->SchemaType = complexType; - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxExclusiveFacet Example/CPP/maxexclusivefacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxExclusiveFacet Example/CPP/maxexclusivefacet.cpp deleted file mode 100644 index a66dd7e2553..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxExclusiveFacet Example/CPP/maxexclusivefacet.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ WaitQueueLengthType = gcnew XmlSchemaSimpleType(); - WaitQueueLengthType->Name = "WaitQueueLengthType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMaxExclusiveFacet^ maxExclusive = gcnew XmlSchemaMaxExclusiveFacet(); - maxExclusive->Value = "5"; - restriction->Facets->Add(maxExclusive); - - WaitQueueLengthType->Content = restriction; - - schema->Items->Add(WaitQueueLengthType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Lobby"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ WaitQueueLengthAttribute = gcnew XmlSchemaAttribute(); - WaitQueueLengthAttribute->Name = "WaitQueueLength"; - WaitQueueLengthAttribute->SchemaTypeName = gcnew XmlQualifiedName("WaitQueueLengthType", ""); - complexType->Attributes->Add(WaitQueueLengthAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxInclusiveFacet Example/CPP/maxinclusivefacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxInclusiveFacet Example/CPP/maxinclusivefacet.cpp deleted file mode 100644 index f27f5519922..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxInclusiveFacet Example/CPP/maxinclusivefacet.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ WaitQueueLengthType = gcnew XmlSchemaSimpleType(); - WaitQueueLengthType->Name = "WaitQueueLengthType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMaxInclusiveFacet^ maxInclusive = gcnew XmlSchemaMaxInclusiveFacet(); - maxInclusive->Value = "5"; - restriction->Facets->Add(maxInclusive); - - WaitQueueLengthType->Content = restriction; - - schema->Items->Add(WaitQueueLengthType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Lobby"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ WaitQueueLengthAttribute = gcnew XmlSchemaAttribute(); - WaitQueueLengthAttribute->Name = "WaitQueueLength"; - WaitQueueLengthAttribute->SchemaTypeName = gcnew XmlQualifiedName("WaitQueueLengthType", ""); - complexType->Attributes->Add(WaitQueueLengthAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxLengthFacet Example/CPP/maxlengthfacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxLengthFacet Example/CPP/maxlengthfacet.cpp deleted file mode 100644 index b50d96ac18d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxLengthFacet Example/CPP/maxlengthfacet.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ ZipCodeType = gcnew XmlSchemaSimpleType(); - ZipCodeType->Name = "ZipCodeType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMaxLengthFacet^ maxLength = gcnew XmlSchemaMaxLengthFacet(); - maxLength->Value = "10"; - restriction->Facets->Add(maxLength); - - ZipCodeType->Content = restriction; - - schema->Items->Add(ZipCodeType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Address"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ ZipCodeAttribute = gcnew XmlSchemaAttribute(); - ZipCodeAttribute->Name = "ZipCode"; - ZipCodeAttribute->SchemaTypeName = gcnew XmlQualifiedName("ZipCodeType", ""); - - complexType->Attributes->Add(ZipCodeAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinExclusiveFacet Example/CPP/minexclusivefacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinExclusiveFacet Example/CPP/minexclusivefacet.cpp deleted file mode 100644 index 34816fb1131..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinExclusiveFacet Example/CPP/minexclusivefacet.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ OrderQuantityType = gcnew XmlSchemaSimpleType(); - OrderQuantityType->Name = "OrderQuantityType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMinExclusiveFacet^ MinExclusive = gcnew XmlSchemaMinExclusiveFacet(); - MinExclusive->Value = "5"; - restriction->Facets->Add(MinExclusive); - - OrderQuantityType->Content = restriction; - - schema->Items->Add(OrderQuantityType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "item"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ OrderQuantityAttribute = gcnew XmlSchemaAttribute(); - OrderQuantityAttribute->Name = "OrderQuantity"; - OrderQuantityAttribute->SchemaTypeName = gcnew XmlQualifiedName("OrderQuantityType", ""); - complexType->Attributes->Add(OrderQuantityAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinInclusiveFacet Example/CPP/mininclusivefacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinInclusiveFacet Example/CPP/mininclusivefacet.cpp deleted file mode 100644 index 8b460bf9a13..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinInclusiveFacet Example/CPP/mininclusivefacet.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ OrderQuantityType = gcnew XmlSchemaSimpleType(); - OrderQuantityType->Name = "OrderQuantityType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMinInclusiveFacet^ minInclusive = gcnew XmlSchemaMinInclusiveFacet(); - minInclusive->Value = "5"; - restriction->Facets->Add(minInclusive); - - OrderQuantityType->Content = restriction; - - schema->Items->Add(OrderQuantityType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "item"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ OrderQuantityAttribute = gcnew XmlSchemaAttribute(); - OrderQuantityAttribute->Name = "OrderQuantity"; - OrderQuantityAttribute->SchemaTypeName = gcnew XmlQualifiedName("OrderQuantityType", ""); - complexType->Attributes->Add(OrderQuantityAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinLengthFacet Example/CPP/minlengthfacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinLengthFacet Example/CPP/minlengthfacet.cpp deleted file mode 100644 index 7bc0e93f86c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinLengthFacet Example/CPP/minlengthfacet.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ ZipCodeType = gcnew XmlSchemaSimpleType(); - ZipCodeType->Name = "ZipCodeType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMinLengthFacet^ minLength = gcnew XmlSchemaMinLengthFacet(); - minLength->Value = "5"; - restriction->Facets->Add(minLength); - - ZipCodeType->Content = restriction; - - schema->Items->Add(ZipCodeType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Address"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ ZipCodeAttribute = gcnew XmlSchemaAttribute(); - ZipCodeAttribute->Name = "ZipCode"; - ZipCodeAttribute->SchemaTypeName = gcnew XmlQualifiedName("ZipCodeType", ""); - complexType->Attributes->Add(ZipCodeAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaPatternFacet Example/CPP/patternfacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaPatternFacet Example/CPP/patternfacet.cpp deleted file mode 100644 index c21f9400afa..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaPatternFacet Example/CPP/patternfacet.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ ZipCodeType = gcnew XmlSchemaSimpleType(); - ZipCodeType->Name = "ZipCodeType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaPatternFacet^ pattern = gcnew XmlSchemaPatternFacet(); - pattern->Value = "[0-9]{5}(-[0-9]{4})?"; - restriction->Facets->Add(pattern); - - ZipCodeType->Content = restriction; - - schema->Items->Add(ZipCodeType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Address"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ ZipCodeAttribute = gcnew XmlSchemaAttribute(); - ZipCodeAttribute->Name = "ZipCode"; - ZipCodeAttribute->SchemaTypeName = gcnew XmlQualifiedName("ZipCodeType", ""); - complexType->Attributes->Add(ZipCodeAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaSimpleTypeUnion Example/CPP/simpletypeunion.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaSimpleTypeUnion Example/CPP/simpletypeunion.cpp deleted file mode 100644 index 2f67440b88f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaSimpleTypeUnion Example/CPP/simpletypeunion.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ StringOrIntType = gcnew XmlSchemaSimpleType(); - StringOrIntType->Name = "StringOrIntType"; - schema->Items->Add(StringOrIntType); - - // - XmlSchemaSimpleTypeUnion^ union1 = gcnew XmlSchemaSimpleTypeUnion(); - StringOrIntType->Content = union1; - - // - XmlSchemaSimpleType^ simpleType1 = gcnew XmlSchemaSimpleType(); - union1->BaseTypes->Add(simpleType1); - - // - XmlSchemaSimpleTypeRestriction^ restriction1 = gcnew XmlSchemaSimpleTypeRestriction(); - restriction1->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - simpleType1->Content = restriction1; - - // - XmlSchemaSimpleType^ simpleType2 = gcnew XmlSchemaSimpleType(); - union1->BaseTypes->Add(simpleType2); - - // - XmlSchemaSimpleTypeRestriction^ restriction2 = gcnew XmlSchemaSimpleTypeRestriction(); - restriction2->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - simpleType2->Content = restriction2; - - - // - XmlSchemaElement^ elementSize = gcnew XmlSchemaElement(); - elementSize->Name = "size"; - elementSize->SchemaTypeName = gcnew XmlQualifiedName("StringOrIntType"); - schema->Items->Add(elementSize); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaUnique Example/CPP/unique.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaUnique Example/CPP/unique.cpp deleted file mode 100644 index 27611f0c5e7..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaUnique Example/CPP/unique.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaComplexType^ customerOrderType = gcnew XmlSchemaComplexType(); - customerOrderType->Name = "customerOrderType"; - - // - XmlSchemaSequence^ sequence1 = gcnew XmlSchemaSequence(); - - // - XmlSchemaElement^ item = gcnew XmlSchemaElement(); - item->MinOccurs = 0; - item->MaxOccursString = "unbounded"; - item->Name = "item"; - - // - XmlSchemaComplexType^ ct1 = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ itemID = gcnew XmlSchemaAttribute(); - itemID->Name = "itemID"; - itemID->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - ct1->Attributes->Add(itemID); - - // - item->SchemaType = ct1; - - // - sequence1->Items->Add(item); - customerOrderType->Particle = sequence1; - - // - XmlSchemaAttribute^ CustomerID = gcnew XmlSchemaAttribute(); - CustomerID->Name = "CustomerID"; - CustomerID->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - customerOrderType->Attributes->Add(CustomerID); - - // - schema->Items->Add(customerOrderType); - - // - XmlSchemaElement^ ordersByCustomer = gcnew XmlSchemaElement(); - ordersByCustomer->Name = "ordersByCustomer"; - - // - XmlSchemaComplexType^ ct2 = gcnew XmlSchemaComplexType(); - - // - XmlSchemaSequence^ sequence2 = gcnew XmlSchemaSequence(); - - // - XmlSchemaElement^ customerOrders = gcnew XmlSchemaElement(); - customerOrders->MinOccurs = 0; - customerOrders->MaxOccursString = "unbounded"; - customerOrders->Name = "customerOrders"; - customerOrders->SchemaTypeName = gcnew XmlQualifiedName("customerOrderType", ""); - - // - sequence2->Items->Add(customerOrders); - - // - ct2->Particle = sequence2; - ordersByCustomer->SchemaType = ct2; - - // - XmlSchemaUnique^ element_unique = gcnew XmlSchemaUnique(); - element_unique->Name = "oneCustomerOrdersforEachCustomerID"; - - // - element_unique->Selector = gcnew XmlSchemaXPath(); - element_unique->Selector->XPath = "customerOrders"; - - // - XmlSchemaXPath^ field = gcnew XmlSchemaXPath(); - field->XPath = "@customerID"; - - // - element_unique->Fields->Add(field); - ordersByCustomer->Constraints->Add(element_unique); - - // - schema->Items->Add(ordersByCustomer); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/CPP/whitespacefacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/CPP/whitespacefacet.cpp deleted file mode 100644 index 82b40e0837b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/CPP/whitespacefacet.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ NameType = gcnew XmlSchemaSimpleType(); - NameType->Name = "NameType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaWhiteSpaceFacet^ whiteSpace = gcnew XmlSchemaWhiteSpaceFacet(); - whiteSpace->Value = "collapse"; - restriction->Facets->Add(whiteSpace); - - NameType->Content = restriction; - - schema->Items->Add(NameType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "LastName"; - element->SchemaTypeName = gcnew XmlQualifiedName("NameType", ""); - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/IHasXmlNode.GetNode/CPP/hasxmlnode.cpp b/snippets/cpp/VS_Snippets_Data/IHasXmlNode.GetNode/CPP/hasxmlnode.cpp deleted file mode 100644 index 31d19ed131b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/IHasXmlNode.GetNode/CPP/hasxmlnode.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::XPath; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - - // Create an XPathNavigator and select all books by Plato. - XPathNavigator^ nav = doc->CreateNavigator(); - XPathNodeIterator^ ni = nav->Select("descendant::book[author/name='Plato']"); - ni->MoveNext(); - - // Get the first matching node and change the book price. - XmlNode^ book = dynamic_cast(ni->Current)->GetNode(); - book->LastChild->InnerText = "12.95"; - Console::WriteLine( book->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/IXmlLineInfo/CPP/lineinfo.cpp b/snippets/cpp/VS_Snippets_Data/IXmlLineInfo/CPP/lineinfo.cpp deleted file mode 100644 index 8bc4192df74..00000000000 --- a/snippets/cpp/VS_Snippets_Data/IXmlLineInfo/CPP/lineinfo.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XML fragment to be parsed. - String^ xmlFrag = "\n" - "\n" - "\n" - "240\n" - "\n" - "\n"; - - // Create the XmlNamespaceManager. - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( gcnew NameTable ); - - // Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::None ); - - // Create the reader. - XmlValidatingReader^ reader = gcnew XmlValidatingReader( xmlFrag,XmlNodeType::Element,context ); - IXmlLineInfo^ lineInfo = (dynamic_cast(reader)); - if ( lineInfo->HasLineInfo() ) - { - - // Parse the XML and display each node. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( " {0} {1}, {2} ", reader->Depth, lineInfo->LineNumber, lineInfo->LinePosition ); - Console::WriteLine( "< {0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( " {0} {1}, {2} ", reader->Depth, lineInfo->LineNumber, lineInfo->LinePosition ); - Console::WriteLine( " {0}", reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::Write( " {0} {1}, {2} ", reader->Depth, lineInfo->LineNumber, lineInfo->LinePosition ); - Console::WriteLine( "", reader->Name ); - break; - } - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/NameTable/CPP/nametable.cpp b/snippets/cpp/VS_Snippets_Data/NameTable/CPP/nametable.cpp deleted file mode 100644 index 27ae8903478..00000000000 --- a/snippets/cpp/VS_Snippets_Data/NameTable/CPP/nametable.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - - // - NameTable^ nt = gcnew NameTable; - Object^ book = nt->Add( "book" ); - Object^ price = nt->Add( "price" ); - - // Create the reader. - XmlReaderSettings ^ settings = gcnew XmlReaderSettings; - settings->NameTable = nt; - XmlReader^ reader = XmlReader::Create( (String^)"books.xml", settings ); - reader->MoveToContent(); - reader->ReadToDescendant( "book" ); - if ( System::Object::ReferenceEquals( book, reader->Name ) ) - { - - // Do additional processing. - } - // - //Close the reader. - reader->Close(); -} - diff --git a/snippets/cpp/VS_Snippets_Data/ValidationEventArgs.Severity/CPP/severity.cpp b/snippets/cpp/VS_Snippets_Data/ValidationEventArgs.Severity/CPP/severity.cpp deleted file mode 100644 index 711f1bfbba1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/ValidationEventArgs.Severity/CPP/severity.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class Sample -{ -private: - static void Validate(String^ filename, XmlSchemaSet^ schemaSet) - { - Console::WriteLine(); - Console::WriteLine("\r\nValidating XML file {0}...", filename->ToString()); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema in schemaSet->Schemas()) - { - compiledSchema = schema; - } - - XmlReaderSettings^ settings = gcnew XmlReaderSettings(); - settings->Schemas->Add(compiledSchema); - settings->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallBack); - settings->ValidationType = ValidationType::Schema; - - //Create the schema validating reader. - XmlReader^ vreader = XmlReader::Create(filename, settings); - - while (vreader->Read()) { } - - //Close the reader. - vreader->Close(); - } - - //Display any warnings or errors. - static void ValidationCallBack(Object^ sender, ValidationEventArgs^ args) - { - if (args->Severity == XmlSeverityType::Warning) - Console::WriteLine("\tWarning: Matching schema not found. No validation occurred." + args->Message); - else - Console::WriteLine("\tValidation error: " + args->Message); - } - -public: - static void Main() - { - //Load the XmlSchemaSet. - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->Add("urn:bookstore-schema", "books.xsd"); - - //Validate the file using the schema stored in the schema set. - //Any elements belonging to the namespace "urn:cd-schema" generate - //a warning because there is no schema matching that namespace. - Validate("store.xml", schemaSet); - Console::ReadLine(); - } -}; - -int main() -{ - Sample::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp b/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp deleted file mode 100644 index beabf44763b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp +++ /dev/null @@ -1,1166 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::XPath; -using namespace System::Collections; - -ref class XPathNavigatorMethods -{ -public: - - static String^ contosobooks = "C:\\Documents and Settings\\dylanm\\My Documents\\contosoBooks.xml"; - - static void XPathNavigatorMethods_AppendChild1() - { - // XPathNavigator->AppendChild() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlWriter^ pages = navigator->AppendChild(); - pages->WriteElementString("pages", "100"); - pages->Close(); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_AppendChild2() - { - // XPathNavigator->AppendChild(string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - navigator->AppendChild("100"); - - Console::WriteLine(navigator->OuterXml); - // - } - - - static void XPathNavigatorMethods_AppendChild3() - { - // XPathNavigator->AppendChile(XmlReader^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlReader^ pages = XmlReader::Create(gcnew StringReader("100")); - - navigator->AppendChild(pages); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_AppendChild4() - { - // XPathNavigator->AppendChild(XPathNavigator^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlDocument^ childNodes = gcnew XmlDocument(); - childNodes->Load(gcnew StringReader("100")); - XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator(); - - - if (childNodesNavigator->MoveToChild("pages", "http://www.contoso.com/books")) - { - navigator->AppendChild(childNodesNavigator); - } - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_AppendChildElement() - { - // XPathNavigator->AppendChildElement(string, string, string, string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - navigator->AppendChildElement(navigator->Prefix, "pages", navigator->LookupNamespace(navigator->Prefix), "100"); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_Clone() - { - // XPathNavigator->Clone() - - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - // Select all books authored by Melville. - XPathNodeIterator^ nodes = navigator->Select("descendant::book[author/last-name='Melville']"); - - while (nodes->MoveNext()) - { - // Clone the navigator returned by the Current property. - // Use the cloned navigator to get the title element. - XPathNavigator^ clone = nodes->Current->Clone(); - clone->MoveToFirstChild(); - Console::WriteLine("Book title: {0}", clone->Value); - } - // - } - - static void XPathNavigatorMethods_CreateAttribute() - { - // XPathNavigator->CreateAttribute(string, string, string, string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->CreateAttribute("", "discount", "", "1.00"); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_CreateAttributes() - { - // XPathNavigator->CreateAttributes() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlWriter^ attributes = navigator->CreateAttributes(); - - attributes->WriteAttributeString("discount", "1.00"); - attributes->WriteAttributeString("currency", "USD"); - attributes->Close(); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_DeleteSelf() - { - // XPathNavigator->DeleteSelf() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->DeleteSelf(); - - Console::WriteLine("Position after delete: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_DeleteRange() - { - // XPathNavigator->DeleteRange() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(document->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - XPathNavigator^ first = navigator->SelectSingleNode("/bk:bookstore/bk:book[1]", manager); - XPathNavigator^ last = navigator->SelectSingleNode("/bk:bookstore/bk:book[2]", manager); - - navigator->MoveTo(first); - navigator->DeleteRange(last); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_Evaluate1() - { - // XPathNavigator->Evaluate(string) - - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - Double total = (double)navigator->Evaluate("sum(descendant::book/price)"); - Console::WriteLine("Total price for all books: {0}", total.ToString()); - // - } - - static void XPathNavigatorMethods_Evaluate2() - { - // XPathNavigator->Evaluate(XPathExpression) - - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathExpression^ query = navigator->Compile("sum(descendant::book/price)"); - - Double total = (double)navigator->Evaluate(query); - Console::WriteLine("Total price for all books: {0}", total.ToString()); - // - } - - static void XPathNavigatorMethods_Evaluate3() - { - // XPathNavigator->Evaluate(string, IXmlNamespaceResolver) - - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(navigator->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - Double total = (double)navigator->Evaluate("sum(descendant::bk:book/bk:price)", manager); - Console::WriteLine("Total price for all books: {0}", total.ToString()); - // - } - - static void XPathNavigatorMethods_Evaluate4() - { - // XPathNavigator->Evaluate(XPathExpression, XPathNodeIterator^) - - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathNodeIterator^ nodes = navigator->Select("//book"); - XPathExpression^ query = nodes->Current->Compile("sum(descendant::price)"); - - Double total = (double)navigator->Evaluate(query, nodes); - Console::WriteLine("Total price for all books: {0}", total.ToString()); - // - } - - static void XPathNavigatorMethods_InsertAfter1() - { - // XPathNavigator->InsertAfter() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlWriter^ pages = navigator->InsertAfter(); - pages->WriteElementString("pages", "100"); - pages->Close(); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertAfter2() - { - // XPathNavigator->InsertAfter(string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->InsertAfter("100"); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertAfter3() - { - // XPathNavigator->InsertAfter(XmlReader^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlReader^ pages = XmlReader::Create(gcnew StringReader("100")); - - navigator->InsertAfter(pages); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertAfter4() - { - // XPathNavigator->InsertAfter(XPathNavigator^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlDocument^ childNodes = gcnew XmlDocument(); - childNodes->Load(gcnew StringReader("100")); - XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator(); - - navigator->InsertAfter(childNodesNavigator); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertBefore1() - { - // XPathNavigator->InsertBefore() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlWriter^ pages = navigator->InsertBefore(); - pages->WriteElementString("pages", "100"); - pages->Close(); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertBefore2() - { - // XPathNavigator->InsertBefore(string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->InsertBefore("100"); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertBefore3() - { - // XPathNavigator->InsertBefore(XmlReader^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlReader^ pages = XmlReader::Create(gcnew StringReader("100")); - - navigator->InsertBefore(pages); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertBefore4() - { - // XPathNavigator->InsertBefore(XPathNavigator^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlDocument^ childNodes = gcnew XmlDocument(); - childNodes->Load(gcnew StringReader("100")); - XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator(); - - navigator->InsertBefore(childNodesNavigator); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertElementAfter() - { - // XPathNavigator->InsertElementAfter(string, string, string, string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->InsertElementAfter(navigator->Prefix, "pages", navigator->LookupNamespace(navigator->Prefix), "100"); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertElementBefore() - { - // XPathNavigator->InsertElementBefore(string, string, string, string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->InsertElementBefore(navigator->Prefix, "pages", navigator->LookupNamespace(navigator->Prefix), "100"); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_Matches() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - // Select all book nodes. - XPathNodeIterator^ nodes = navigator->SelectDescendants("book", "", false); - - // Select all book nodes that have the matching attribute value. - XPathExpression^ expr = navigator->Compile("book[@genre='novel']"); - while (nodes->MoveNext()) - { - XPathNavigator^ navigator2 = nodes->Current->Clone(); - if (navigator2->Matches(expr)) - { - navigator2->MoveToFirstChild(); - Console::WriteLine("Book title: {0}", navigator2->Value); - } - } - // - } - - static void XPathNavigatorMethods_MoveToFollowing1() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToFollowing(XPathNodeType::Element); - - Console::WriteLine("Position: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_MoveToFollowing2() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToFollowing("price", "http://www.contoso.com/books"); - - Console::WriteLine("Position: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_MoveToFollowing3() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToFollowing("price", "http://www.contoso.com/books"); - XPathNavigator^ boundary = navigator->Clone(); - - navigator->MoveToRoot(); - - while (navigator->MoveToFollowing(XPathNodeType::Text, boundary)) - { - Console::WriteLine(navigator->OuterXml); - } - // - } - - static void XPathNavigatorMethods_MoveToFollowing4() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToFollowing("book", "http://www.contoso.com/books"); - XPathNavigator^ boundary = navigator->Clone(); - boundary->MoveToFollowing("first-name", "http://www.contoso.com/books"); - - navigator->MoveToFollowing("price", "http://www.contoso.com/books", boundary); - - Console::WriteLine("Position (after boundary): {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - - navigator->MoveToFollowing("title", "http://www.contoso.com/books", boundary); - - Console::WriteLine("Position (before boundary): {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - // - static void XPathNavigatorMethods_MoveToNext() - { - - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - XPathNodeIterator^ nodeset = navigator->Select("descendant::book[author/last-name='Melville']"); - - while (nodeset->MoveNext()) - { - // Clone iterator here when working with it. - RecursiveWalk(nodeset->Current->Clone()); - } - } - - static void RecursiveWalk(XPathNavigator^ navigator) - { - switch (navigator->NodeType) - { - case XPathNodeType::Element: - if (navigator->Prefix == String::Empty) - Console::WriteLine("<{0}>", navigator->LocalName); - else - Console::Write("<{0}:{1}>", navigator->Prefix, navigator->LocalName); - Console::WriteLine("\t" + navigator->NamespaceURI); - break; - case XPathNodeType::Text: - Console::WriteLine("\t" + navigator->Value); - break; - } - - if (navigator->MoveToFirstChild()) - { - do - { - RecursiveWalk(navigator); - } while (navigator->MoveToNext()); - - navigator->MoveToParent(); - if (navigator->NodeType == XPathNodeType::Element) - Console::WriteLine("", navigator->Name); - } - else - { - if (navigator->NodeType == XPathNodeType::Element) - { - Console::WriteLine("", navigator->Name); - } - } - } - // - - static void XPathNavigatorMethods_PrependChild1() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlWriter^ pages = navigator->PrependChild(); - pages->WriteElementString("pages", "100"); - pages->Close(); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_PrependChild2() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - navigator->PrependChild("100"); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_PrependChild3() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlReader^ pages = XmlReader::Create(gcnew StringReader("100")); - - navigator->PrependChild(pages); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_PrependChild4() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlDocument^ childNodes = gcnew XmlDocument(); - childNodes->Load(gcnew StringReader("100")); - XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator(); - - navigator->PrependChild(childNodesNavigator); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_PrependChildElement() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - navigator->PrependChildElement(navigator->Prefix, "pages", navigator->LookupNamespace(navigator->Prefix), "100"); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_ReadSubtree() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlReader^ reader = navigator->ReadSubtree(); - - while (reader->Read()) - { - Console::WriteLine(reader->ReadInnerXml()); - } - - reader->Close(); - // - } - - static void XPathNavigatorMethods_ReplaceRange() - { - // XPathNavigator->ReplaceRange() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(document->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - XPathNavigator^ first = navigator->SelectSingleNode("/bk:bookstore/bk:book[1]", manager); - XPathNavigator^ last = navigator->SelectSingleNode("/bk:bookstore/bk:book[2]", manager); - - navigator->MoveTo(first); - XmlWriter^ newRange = navigator->ReplaceRange(last); - newRange->WriteStartElement("book"); - newRange->WriteAttributeString("genre", ""); - newRange->WriteAttributeString("publicationdate", "2005-04-07"); - newRange->WriteAttributeString("ISBN", "0"); - newRange->WriteStartElement("title"); - newRange->WriteString("New Book"); - newRange->WriteEndElement(); - newRange->WriteStartElement("author"); - newRange->WriteStartElement("first-name"); - newRange->WriteString("First Name"); - newRange->WriteEndElement(); - newRange->WriteStartElement("last-name"); - newRange->WriteString("Last Name"); - newRange->WriteEndElement(); - newRange->WriteEndElement(); - newRange->WriteElementString("price", "$0.00"); - newRange->WriteEndElement(); - newRange->Close(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_ReplaceSelf1() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->ReplaceSelf("100"); - - Console::WriteLine("Position after delete: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_ReplaceSelf2() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlReader^ pages = XmlReader::Create(gcnew StringReader("100")); - - navigator->ReplaceSelf(pages); - - Console::WriteLine("Position after delete: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_ReplaceSelf3() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlDocument^ childNodes = gcnew XmlDocument(); - childNodes->Load(gcnew StringReader("100")); - XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator(); - - navigator->ReplaceSelf(childNodesNavigator); - - Console::WriteLine("Position after delete: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_Select1() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathNodeIterator^ nodes = navigator->Select("/bookstore/book"); - nodes->MoveNext(); - XPathNavigator^ nodesNavigator = nodes->Current; - - XPathNodeIterator^ nodesText = nodesNavigator->SelectDescendants(XPathNodeType::Text, false); - - while (nodesText->MoveNext()) - Console::WriteLine(nodesText->Current->Value); - // - } - - static void XPathNavigatorMethods_Select2() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathExpression^ query = navigator->Compile("/bookstore/book"); - XPathNodeIterator^ nodes = navigator->Select(query); - XPathNavigator^ nodesNavigator = nodes->Current; - - XPathNodeIterator^ nodesText = nodesNavigator->SelectDescendants(XPathNodeType::Text, false); - - while (nodesText->MoveNext()) - { - Console::WriteLine(nodesText->Current->Value); - } - // - } - - static void XPathNavigatorMethods_Select3() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(navigator->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - XPathNodeIterator^ nodes = navigator->Select("/bk:bookstore/bk:book/bk:price", manager); - // Move to the first node bk:price node. - if(nodes->MoveNext()) - { - // Now nodes.Current points to the first selected node. - XPathNavigator^ nodesNavigator = nodes->Current; - - // Select all the descendants of the current price node. - XPathNodeIterator^ nodesText = nodesNavigator->SelectDescendants(XPathNodeType::Text, false); - - while(nodesText->MoveNext()) - { - Console::WriteLine(nodesText->Current->Value); - } - } - // - } - - static void XPathNavigatorMethods_SelectAncestorsChildrenDescendants() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - // Select all the descendant nodes of the book node. - XPathNodeIterator^ bookDescendants = navigator->SelectDescendants("", "http://www.contoso.com/books", false); - - // Display the LocalName of each descendant node. - Console::WriteLine("Descendant nodes of the book node:"); - while (bookDescendants->MoveNext()) - { - Console::WriteLine(bookDescendants->Current->Name); - } - - // Select all the child nodes of the book node. - XPathNodeIterator^ bookChildren = navigator->SelectChildren("", "http://www.contoso.com/books"); - - // Display the LocalName of each child node. - Console::WriteLine("\nChild nodes of the book node:"); - while (bookChildren->MoveNext()) - { - Console::WriteLine(bookChildren->Current->Name); - } - - // Select all the ancestor nodes of the title node. - navigator->MoveToChild("title", "http://www.contoso.com/books"); - - XPathNodeIterator^ bookAncestors = navigator->SelectAncestors("", "http://www.contoso.com/books", false); - - // Display the LocalName of each ancestor node. - Console::WriteLine("\nAncestor nodes of the title node:"); - - while (bookAncestors->MoveNext()) - { - Console::WriteLine(bookAncestors->Current->Name); - } - // - } - - static void XPathNavigatorMethods_SelectSingleNode1() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathNavigator^ node = navigator->SelectSingleNode("//title"); - Console::WriteLine(node->InnerXml); - // - } - - static void XPathNavigatorMethods_SelectSingleNode2() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathExpression^ query = navigator->Compile("//title"); - - XPathNavigator^ node = navigator->SelectSingleNode(query); - Console::WriteLine(node->InnerXml); - // - } - - static void XPathNavigatorMethods_SelectSingleNode3() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(navigator->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - XPathNavigator^ node = navigator->SelectSingleNode("//bk:title", manager); - Console::WriteLine(node->InnerXml); - // - } - - static void XPathNavigatorMethods_SetTypedValue() - { - // - XmlReaderSettings^ settings = gcnew XmlReaderSettings(); - settings->Schemas->Add("http://www.contoso.com/books", "contosoBooks.xsd"); - settings->ValidationType = ValidationType::Schema; - - XmlReader^ reader = XmlReader::Create("contosoBooks.xml", settings); - XmlDocument^ document = gcnew XmlDocument(); - document->Load(reader); - - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - Decimal^ price = gcnew Decimal(19.99); - navigator->SetTypedValue(price); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_SetValue() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(navigator->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - for each (XPathNavigator^ nav in navigator->Select("//bk:price", manager)) - { - if(nav->Value == "11.99") - { - nav->SetValue("12.99"); - } - } - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_WriteSubtree() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlWriter^ writer = XmlWriter::Create("contosoBook.xml"); - navigator->WriteSubtree(writer); - - writer->Close(); - // - } - - static void XPathNavigatorMethods_MoveToNextAttribute() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - // Select all book nodes and display all attributes on each book. - XPathNodeIterator^ nodes = navigator->SelectDescendants("book", "", false); - while (nodes->MoveNext()) - { - XPathNavigator^ navigator2 = nodes->Current->Clone(); - navigator2->MoveToFirstAttribute(); - Console::WriteLine("{0} = {1}", navigator2->Name, navigator2->Value); - - while (navigator2->MoveToNextAttribute()) - { - Console::WriteLine("{0} = {1}", navigator2->Name, navigator2->Value); - } - - Console::WriteLine(); - } - // - } - - static void XPathNavigatorMethods_BasicMoveTos() - { - // - // Load the XML document. - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - - // Create the XPathNavigator. - XPathNavigator^ navigator = document->CreateNavigator(); - - // Create an XmlNamespaceManager used to handle namespaces - // found in the XML document. - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(document->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - // Move to the last book node using the SelectSingleNode method. - navigator = navigator->SelectSingleNode("//bk:book[last()]", manager); - Console::WriteLine("Last book node: \n===============\n{0}", navigator->OuterXml); - - // Move to the previous book node and write it to the console - // if the move was successful. - if (navigator->MoveToPrevious()) - { - Console::WriteLine("\nSecond book node: \n=================\n{0}", - navigator->OuterXml); - } - - // Move to the first book node and write it to the console - // if the move was successful. - if (navigator->MoveToFirst()) - { - Console::WriteLine("\nFirst book node: \n================\n{0}", - navigator->OuterXml); - } - - // Move to the parent bookstore node and write it to the console - // if the move was successful. - if (navigator->MoveToParent()) - { - Console::WriteLine("\nParent bookstore node: \n======================\n{0}", - navigator->OuterXml); - } - - // Move to the first child node of the bookstore node and write - // it to the console if the move was successful. - if (navigator->MoveToFirstChild()) - { - Console::WriteLine("\nFirst book node: \n================\n{0}", - navigator->OuterXml); - } - - // Move to the root node and write it to the console. - navigator->MoveToRoot(); - Console::WriteLine("\nRoot node: \n==========\n{0}", - navigator->OuterXml); - // - } - static void XPathNavigatorMethods_TwoWaysToIterateOverXPathNavigator() - { - XPathDocument^ doc = gcnew XPathDocument(gcnew StringReader("")); - XPathNavigator^ nav = doc->CreateNavigator(); - XPathNodeIterator^ nodeIterator = nav->SelectDescendants("", "", false); - - // - while (nodeIterator->MoveNext()) - { - XPathNavigator^ n = nodeIterator->Current; - Console::WriteLine(n->LocalName); - } - // - - // - for each (XPathNavigator^ n in nodeIterator) - Console::WriteLine(n->LocalName); - // - } - - -}; - -int main() -{ - return 0; -}; \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp b/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp deleted file mode 100644 index 98a87366e0c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::XPath; -using namespace System::Collections; - -class XPathNavigatorProperties -{ -public: - - static void XPathNavigatorProperties_CanEdit() - { - // - XPathDocument^ readOnlyDocument = gcnew XPathDocument("books.xml"); - XPathNavigator^ readOnlyNavigator = readOnlyDocument->CreateNavigator(); - - XmlDocument^ editableDocument = gcnew XmlDocument(); - editableDocument->Load("books.xml"); - XPathNavigator^ editableNavigator = editableDocument->CreateNavigator(); - - Console::WriteLine("XPathNavigator.CanEdit from XPathDocument: {0}", readOnlyNavigator->CanEdit); - Console::WriteLine("XPathNavigator.CanEdit from XmlDocument: {0}", editableNavigator->CanEdit); - // - } - - static void XPathNavigatorProperties_InnerXml() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - Console::WriteLine(navigator->InnerXml); - // - } - - static void XPathNavigatorProperties_NavigatorComparer() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - Hashtable^ table = gcnew Hashtable(XPathNavigator::NavigatorComparer); - - // Add nodes to the Hashtable. - for each (XPathNavigator^ navigator2 in navigator->Select("//book")) - { - Object^ value = navigator2->Evaluate("string(./title)"); - table->Add(navigator2->Clone(), value); - Console::WriteLine("Added book with title {0}", value); - } - - Console::WriteLine(table->Count); - Console::WriteLine("Does the Hashtable have the book \"The Confidence Man\"?"); - Console::WriteLine(table->Contains(navigator->SelectSingleNode("//book[title='The Confidence Man']"))); - // - } - - static void XPathNavigatorProperties_OuterXml() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorProperties_ValueAs() - { - // - XPathDocument^ document = gcnew XPathDocument("valueas.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - // ValueAsBoolean - navigator->MoveToChild("root", ""); - navigator->MoveToChild("booleanElement", ""); - bool^ booleanValue = navigator->ValueAsBoolean; - Console::WriteLine(navigator->LocalName + ": " + booleanValue); - - // ValueAsDateTime - navigator->MoveToNext("dateTimeElement", ""); - DateTime^ dateTimeValue = navigator->ValueAsDateTime; - Console::WriteLine(navigator->LocalName + ": " + dateTimeValue); - - // ValueAsDouble, ValueAsInt32, ValueAsInt64, ValueAsSingle - navigator->MoveToNext("numberElement", ""); - Double doubleValue = navigator->ValueAsDouble; - Int32 int32Value = navigator->ValueAsInt; - Int64 int64Value = navigator->ValueAsLong; - Console::WriteLine(navigator->LocalName + ": " + doubleValue); - Console::WriteLine(navigator->LocalName + ": " + int32Value); - Console::WriteLine(navigator->LocalName + ": " + int64Value); - // - } - - static void XPathNavigatorProperties_ValueType() - { - // - // Create an XmlReaderSettings object with the contosoBooks.xsd schema. - XmlReaderSettings^ settings = gcnew XmlReaderSettings(); - settings->Schemas->Add("http://www.contoso.com/books", "contosoBooks.xsd"); - settings->ValidationType = ValidationType::Schema; - - // Create an XmlReader object with the contosoBooks.xml file and its schema. - XmlReader^ reader = XmlReader::Create("contosoBooks.xml", settings); - - XPathDocument^ document = gcnew XPathDocument(reader); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - // Display the current type of the price element. - Console::WriteLine(navigator->ValueType); - - // Get the value of the price element as a string and display it. - String^ price = dynamic_cast(navigator->ValueAs(String::typeid)); - Console::WriteLine(price); - // - } -}; - -int main() -{ - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp b/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp deleted file mode 100644 index 47d9622fae0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Encode and decode a name with spaces. - String^ name1 = XmlConvert::EncodeName( "Order Detail" ); - Console::WriteLine( "Encoded name: {0}", name1 ); - Console::WriteLine( "Decoded name: {0}", XmlConvert::DecodeName( name1 ) ); - - // Encode and decode a local name. - String^ name2 = XmlConvert::EncodeLocalName( "a:book" ); - Console::WriteLine( "Encoded local name: {0}", name2 ); - Console::WriteLine( "Decoded local name: {0}", XmlConvert::DecodeName( name2 ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlConvert.ToDouble/CPP/readData.cpp b/snippets/cpp/VS_Snippets_Data/XmlConvert.ToDouble/CPP/readData.cpp deleted file mode 100644 index c3d8da70f59..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlConvert.ToDouble/CPP/readData.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = gcnew XmlTextReader( "orderData.xml" ); - - //Parse the file and pull out the order date and price. - while ( reader->Read() ) - { - if ( reader->NodeType == XmlNodeType::Element ) - { - if ( reader->Name->Equals( "order" ) ) - { - DateTime orderDate = XmlConvert::ToDateTime( reader->GetAttribute( "date" ) ); - Console::WriteLine( "order date: {0}", orderDate.ToString() ); - } - else - if ( reader->Name->Equals( "price" ) ) - { - Double price = XmlConvert::ToDouble( reader->ReadInnerXml() ); - Console::WriteLine( "price: {0}", price ); - } - } - } - - - //Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlConvert.VerifyName/CPP/verifyname.cpp b/snippets/cpp/VS_Snippets_Data/XmlConvert.VerifyName/CPP/verifyname.cpp deleted file mode 100644 index a3e011767f0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlConvert.VerifyName/CPP/verifyname.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = gcnew XmlTextWriter( "out.xml", nullptr ); - String^ tag = "item name"; - try - { - - // Write the root element. - writer->WriteStartElement( "root" ); - writer->WriteStartElement( XmlConvert::VerifyName( tag ) ); - } - catch ( XmlException^ e ) - { - Console::WriteLine( e->Message ); - Console::WriteLine( "Convert to a valid name..." ); - writer->WriteStartElement( XmlConvert::EncodeName( tag ) ); - } - - writer->WriteString( "hammer" ); - writer->WriteEndElement(); - - // Write the end tag for the root element. - writer->WriteEndElement(); - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlDataDocument.GetRowFromElement/CPP/getrow.cpp b/snippets/cpp/VS_Snippets_Data/XmlDataDocument.GetRowFromElement/CPP/getrow.cpp deleted file mode 100644 index f69ebbfb60c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlDataDocument.GetRowFromElement/CPP/getrow.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; - -int main() -{ - // Create an XmlDataDocument. - XmlDataDocument^ doc = gcnew XmlDataDocument; - - // Load the schema file. - doc->DataSet->ReadXmlSchema( "store.xsd" ); - - // Load the XML data. - doc->Load( "2books.xml" ); - - //Change the price on the first book. - XmlElement^ root = doc->DocumentElement; - DataRow^ row = doc->GetRowFromElement( safe_cast(root->FirstChild) ); - row["price"] = "12.95"; - Console::WriteLine( "Display the modified XML data..." ); - Console::WriteLine( doc->DocumentElement->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlDataDocument.Load/CPP/loadrdr.cpp b/snippets/cpp/VS_Snippets_Data/XmlDataDocument.Load/CPP/loadrdr.cpp deleted file mode 100644 index 631d04fa9a1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlDataDocument.Load/CPP/loadrdr.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; -int main() -{ - // Create an XmlDataDocument. - XmlDataDocument^ doc = gcnew XmlDataDocument; - - // Load the schema file. - doc->DataSet->ReadXmlSchema( "store.xsd" ); - - // Load the XML data. - XmlTextReader^ reader = gcnew XmlTextReader( "2books.xml" ); - reader->MoveToContent(); // Moves the reader to the root node. - doc->Load( reader ); - - // Update the price on the first book using the DataSet methods. - DataTable^ books = doc->DataSet->Tables["book"]; - books->Rows[0]["price"] = "12.95"; - Console::WriteLine( "Display the modified XML data..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlEntity/CPP/entities.cpp b/snippets/cpp/VS_Snippets_Data/XmlEntity/CPP/entities.cpp deleted file mode 100644 index 85250f42094..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlEntity/CPP/entities.cpp +++ /dev/null @@ -1,39 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -public: - static void DisplayEntities( XmlNamedNodeMap^ nMap ) - { - for ( int i = 0; i < nMap->Count; i++ ) - { - XmlEntity^ ent = dynamic_cast(nMap->Item( i )); - Console::Write( " {0} ", ent->NodeType ); - Console::Write( " {0} ", ent->Name ); - Console::Write( " {0} ", ent->NotationName ); - Console::Write( " {0} ", ent->PublicId ); - Console::Write( " {0} ", ent->SystemId ); - Console::WriteLine(); - - } - } - -}; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "doment.xml" ); - Console::WriteLine( "Display information on all entities..." ); - XmlNamedNodeMap^ nMap = doc->DocumentType->Entities; - Sample^ MySample = gcnew Sample; - MySample->DisplayEntities( nMap ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectNodes1/CPP/selectnodes1.cpp b/snippets/cpp/VS_Snippets_Data/XmlNode.SelectNodes1/CPP/selectnodes1.cpp deleted file mode 100644 index 3424276fabf..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectNodes1/CPP/selectnodes1.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Collections; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "booksort.xml" ); - - // Create an XmlNamespaceManager for resolving namespaces. - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( doc->NameTable ); - nsmgr->AddNamespace( "bk", "urn:samples" ); - - // Select and display the value of all the ISBN attributes. - XmlNodeList^ nodeList; - XmlElement^ root = doc->DocumentElement; - nodeList = root->SelectNodes( "/bookstore/book/@bk:ISBN", nsmgr ); - IEnumerator^ myEnum = nodeList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlNode^ isbn = safe_cast(myEnum->Current); - Console::WriteLine( isbn->Value ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode1/CPP/selectsingnode.cpp b/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode1/CPP/selectsingnode.cpp deleted file mode 100644 index 3cc1ad791d3..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode1/CPP/selectsingnode.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "booksort.xml" ); - - //Create an XmlNamespaceManager for resolving namespaces. - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( doc->NameTable ); - nsmgr->AddNamespace( "bk", "urn:samples" ); - - //Select the book node with the matching attribute value. - XmlNode^ book; - XmlElement^ root = doc->DocumentElement; - book = root->SelectSingleNode( "descendant::book->Item[@bk:ISBN='1-861001-57-6']", nsmgr ); - Console::WriteLine( book->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode2/CPP/XmlNode.SelectSingleNode2.cpp b/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode2/CPP/XmlNode.SelectSingleNode2.cpp deleted file mode 100644 index f460ecd9f3d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode2/CPP/XmlNode.SelectSingleNode2.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( L"newbooks.xml" ); - - // Create an XmlNamespaceManager to resolve the default namespace. - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( doc->NameTable ); - nsmgr->AddNamespace( L"bk", L"urn:newbooks-schema" ); - - // Select the first book written by an author whose last name is Atwood. - XmlNode^ book; - XmlElement^ root = doc->DocumentElement; - book = root->SelectSingleNode( L"descendant::bk:book[bk:author/bk:last-name='Atwood']", nsmgr ); - Console::WriteLine( book->OuterXml ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlNodeChangedEventHandler/CPP/nodeevent.cpp b/snippets/cpp/VS_Snippets_Data/XmlNodeChangedEventHandler/CPP/nodeevent.cpp deleted file mode 100644 index ab467b652be..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlNodeChangedEventHandler/CPP/nodeevent.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -public: - void Run( String^ args ) - { - // Create and load the XML document. - Console::WriteLine( "Loading file {0} ...", args ); - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( args ); - - //Create the event handlers. - doc->NodeChanged += gcnew XmlNodeChangedEventHandler( this, &Sample::MyNodeChangedEvent ); - doc->NodeInserted += gcnew XmlNodeChangedEventHandler( this, &Sample::MyNodeInsertedEvent ); - - // Change the book price. - doc->DocumentElement->LastChild->InnerText = "5.95"; - - // Add a new element. - XmlElement^ newElem = doc->CreateElement( "style" ); - newElem->InnerText = "hardcover"; - doc->DocumentElement->AppendChild( newElem ); - Console::WriteLine( "\r\nDisplay the modified XML..." ); - Console::WriteLine( doc->OuterXml ); - } - - // Handle the NodeChanged event. -private: - void MyNodeChangedEvent( Object^ /*src*/, XmlNodeChangedEventArgs^ args ) - { - Console::Write( "Node Changed Event: <{0}> changed", args->Node->Name ); - if ( args->Node->Value != nullptr ) - { - Console::WriteLine( " with value {0}", args->Node->Value ); - } - else - Console::WriteLine( "" ); - } - - // Handle the NodeInserted event. - void MyNodeInsertedEvent( Object^ /*src*/, XmlNodeChangedEventArgs^ args ) - { - Console::Write( "Node Inserted Event: <{0}> inserted", args->Node->Name ); - if ( args->Node->Value != nullptr ) - { - Console::WriteLine( " with value {0}", args->Node->Value ); - } - else - Console::WriteLine( "" ); - } -}; -// End class - -int main() -{ - Sample^ mySample = gcnew Sample; - mySample->Run( "book.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlNotation/CPP/notation.cpp b/snippets/cpp/VS_Snippets_Data/XmlNotation/CPP/notation.cpp deleted file mode 100644 index 5e7a6c8360b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlNotation/CPP/notation.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -void DisplayNotations( XmlNamedNodeMap^ nMap ) -{ - for ( int i = 0; i < nMap->Count; i++ ) - { - XmlNotation^ note = dynamic_cast(nMap->Item( i )); - Console::Write( " {0} ", note->NodeType ); - Console::Write( " {0} ", note->Name ); - Console::Write( " {0} ", note->PublicId ); - Console::Write( " {0} ", note->SystemId ); - Console::WriteLine(); - - } -} - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "doment.xml" ); - Console::WriteLine( "Display information on all notations..." ); - XmlNamedNodeMap^ nMap = doc->DocumentType->Notations; - DisplayNotations( nMap ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.DtdValidate/CPP/XmlReaderSettings.DtdValidate.cpp b/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.DtdValidate/CPP/XmlReaderSettings.DtdValidate.cpp deleted file mode 100644 index a3f97a98a5a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.DtdValidate/CPP/XmlReaderSettings.DtdValidate.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::IO; - -// Display any validation errors. -static void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ e ) -{ - Console::WriteLine( L"Validation Error: {0}", e->Message ); -} - -int main() -{ - // Set the validation settings. - XmlReaderSettings^ settings = gcnew XmlReaderSettings; - settings->DtdProcessing = DtdProcessing::Parse; - settings->ValidationType = ValidationType::DTD; - settings->ValidationEventHandler += gcnew ValidationEventHandler( ValidationCallBack ); - - // Create the XmlReader object. - XmlReader^ reader = XmlReader::Create( L"itemDTD.xml", settings ); - - // Parse the file. - while ( reader->Read() ) - ; - - return 1; -} -// - diff --git a/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.cctor/CPP/XmlReaderSettings.cctor.cpp b/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.cctor/CPP/XmlReaderSettings.cctor.cpp deleted file mode 100644 index 2c42e5cc4eb..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.cctor/CPP/XmlReaderSettings.cctor.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::IO; -int main() -{ - - // - // Set the reader settings. - XmlReaderSettings^ settings = gcnew XmlReaderSettings; - settings->IgnoreComments = true; - settings->IgnoreProcessingInstructions = true; - settings->IgnoreWhitespace = true; - - // - // - // Create a resolver with default credentials. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - resolver->Credentials = System::Net::CredentialCache::DefaultCredentials; - - // Set the reader settings object to use the resolver. - settings->XmlResolver = resolver; - - // Create the XmlReader object. - XmlReader^ reader = XmlReader::Create( L"http://ServerName/data/books.xml", settings ); - - // - // Parse the file. - while ( reader->Read() ) - ; - - return 1; -} - diff --git a/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp b/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp deleted file mode 100644 index f202c678601..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::IO; - -// Display any validation errors. -static void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ e ) -{ - Console::WriteLine( L"Validation Error:\n {0}", e->Message ); - Console::WriteLine(); -} - -int main() -{ - // Create the XmlSchemaSet class. - XmlSchemaSet^ sc = gcnew XmlSchemaSet; - - // Add the schema to the collection. - sc->Add( L"urn:bookstore-schema", L"books.xsd" ); - - // Set the validation settings. - XmlReaderSettings^ settings = gcnew XmlReaderSettings; - settings->ValidationType = ValidationType::Schema; - settings->Schemas = sc; - settings->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallBack); - - // Create the XmlReader object. - XmlReader^ reader = XmlReader::Create( L"booksSchemaFail.xml", settings ); - - // Parse the file. - while ( reader->Read() ) - ; - - return 1; -} -// The example displays output like the following: -// Validation Error: -// The element 'book' in namespace 'urn:bookstore-schema' has invalid child element 'author' -// in namespace 'urn:bookstore-schema'. List of possible elements expected: 'title' in -// namespace 'urn:bookstore-schema'. -// -// Validation Error: -// The element 'author' in namespace 'urn:bookstore-schema' has invalid child element 'name' -// in namespace 'urn:bookstore-schema'. List of possible elements expected: 'first-name' in -// namespace 'urn:bookstore-schema'. -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlSchema.ValidationEventHandler/CPP/schemaevent.cpp b/snippets/cpp/VS_Snippets_Data/XmlSchema.ValidationEventHandler/CPP/schemaevent.cpp deleted file mode 100644 index 8ad92c04292..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSchema.ValidationEventHandler/CPP/schemaevent.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Sample -{ -private: - //Display the schema error information. - static void ValidationCallBack( Object^ sender, ValidationEventArgs^ args ) - { - Console::WriteLine( "Invalid XSD schema: {0}", args->Exception->Message ); - } - -public: - static void main() - { - // Create the schema collection. - XmlSchemaCollection^ xsc = gcnew XmlSchemaCollection; - - //Set an event handler to manage invalid schemas. - xsc->ValidationEventHandler += gcnew ValidationEventHandler( Sample::ValidationCallBack ); - - //Add the schema to the collection. - xsc->Add( nullptr, "invalid.xsd" ); - } -}; - -int main() -{ - Sample::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Add/CPP/schemacolladd.cpp b/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Add/CPP/schemacolladd.cpp deleted file mode 100644 index d496898fad0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Add/CPP/schemacolladd.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Sample -{ -private: - // Display any errors. - static void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ e ) - { - Console::WriteLine( "Validation Error: {0}", e->Message ); - } - -public: - static void main() - { - array^ args = Environment::GetCommandLineArgs(); - String^ UserName = args[ 1 ]; - String^ SecurelyStoredPassword = args[ 2 ]; - String^ Domain = args[ 3 ]; - - // - XmlSchemaCollection^ sc = gcnew XmlSchemaCollection; - sc->ValidationEventHandler += gcnew ValidationEventHandler( Sample::ValidationCallBack ); - - // Create a resolver with the necessary credentials. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - System::Net::NetworkCredential^ nc; - nc = gcnew System::Net::NetworkCredential( UserName,SecurelyStoredPassword,Domain ); - resolver->Credentials = nc; - - // Add the new schema to the collection. - sc->Add( nullptr, gcnew XmlTextReader( "sample.xsd" ), resolver ); - // - - if ( sc->Count > 0 ) - { - XmlTextReader^ tr = gcnew XmlTextReader( "notValidXSD.xml" ); - XmlValidatingReader^ rdr = gcnew XmlValidatingReader( tr ); - - rdr->ValidationType = ValidationType::Schema; - rdr->Schemas->Add( sc ); - rdr->ValidationEventHandler += gcnew ValidationEventHandler( Sample::ValidationCallBack ); - while ( rdr->Read() ); - } - } -}; - -int main() -{ - Sample::main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Basic/CPP/aa.cpp b/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Basic/CPP/aa.cpp deleted file mode 100644 index 16126254e5a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Basic/CPP/aa.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::IO; -public ref class ValidXSD -{ -public: - static void main() - { - XmlSchemaCollection^ sc = gcnew XmlSchemaCollection; - sc->ValidationEventHandler += gcnew ValidationEventHandler( ValidationCallBack ); - sc->Add( nullptr, "books.xsd" ); - if ( sc->Count > 0 ) - { - XmlTextReader^ tr = gcnew XmlTextReader( "notValidXSD.xml" ); - XmlValidatingReader^ rdr = gcnew XmlValidatingReader( tr ); - rdr->ValidationType = ValidationType::Schema; - rdr->Schemas->Add( sc ); - rdr->ValidationEventHandler += gcnew ValidationEventHandler( ValidationCallBack ); - while ( rdr->Read() ) - ; - } - } - - -private: - static void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ e ) - { - Console::WriteLine( "Validation Error: {0}", e->Message ); - } - -}; - -int main() -{ - ValidXSD::main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp b/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp deleted file mode 100644 index 0d338c1f4c0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XmlSchemaInferenceExamples -{ -public: - - static void Main() - { - - } - - static void XmlSchemaInference_OverallExample() - { - // - XmlReader^ reader = XmlReader::Create("contosoBooks.xml"); - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - XmlSchemaInference^ schema = gcnew XmlSchemaInference(); - - schemaSet = schema->InferSchema(reader); - - for each (XmlSchema^ s in schemaSet->Schemas()) - { - s->Write(Console::Out); - } - // - } - - static void XmlSchemaInference_Occurrence() - { - // - XmlReader^ reader = XmlReader::Create("input.xml"); - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - XmlSchemaInference^ schema = gcnew XmlSchemaInference(); - - schema->Occurrence = XmlSchemaInference::InferenceOption::Relaxed; - - schemaSet = schema->InferSchema(reader); - - for each (XmlSchema^ s in schemaSet->Schemas()) - { - s->Write(Console::Out); - } - // - } - - static void XmlSchemaInference_TypeInference() - { - // - XmlReader^ reader = XmlReader::Create("input.xml"); - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - XmlSchemaInference^ schema = gcnew XmlSchemaInference(); - - schema->TypeInference = XmlSchemaInference::InferenceOption::Relaxed; - - schemaSet = schema->InferSchema(reader); - - for each (XmlSchema^ s in schemaSet->Schemas()) - { - s->Write(Console::Out); - } - // - } - - static void XmlSchemaInference_RefinementProcess() - { - // - XmlReader^ reader = XmlReader::Create("item1.xml"); - XmlReader^ reader1 = XmlReader::Create("item2.xml"); - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - XmlSchemaInference^ inference = gcnew XmlSchemaInference(); - schemaSet = inference->InferSchema(reader); - - // Display the inferred schema. - Console::WriteLine("Original schema:\n"); - for each (XmlSchema^ schema in schemaSet->Schemas("http://www.contoso.com/items")) - { - schema->Write(Console::Out); - } - - // Use the additional data in item2.xml to refine the original schema. - schemaSet = inference->InferSchema(reader1, schemaSet); - - // Display the refined schema. - Console::WriteLine("\n\nRefined schema:\n"); - for each (XmlSchema^ schema in schemaSet->Schemas("http://www.contoso.com/items")) - { - schema->Write(Console::Out); - } - // - } -}; - -int main() -{ - XmlSchemaInferenceExamples::Main(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Data/XmlSchemaSetOverall Example/CPP/xmlschemasetexample.cpp b/snippets/cpp/VS_Snippets_Data/XmlSchemaSetOverall Example/CPP/xmlschemasetexample.cpp deleted file mode 100644 index 1f3adf25c44..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSchemaSetOverall Example/CPP/xmlschemasetexample.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -static void booksSettingsValidationEventHandler( Object^ /*sender*/, ValidationEventArgs^ e ) -{ - if ( e->Severity == XmlSeverityType::Warning ) - { - Console::Write( L"WARNING: " ); - Console::WriteLine( e->Message ); - } - else - if ( e->Severity == XmlSeverityType::Error ) - { - Console::Write( L"ERROR: " ); - Console::WriteLine( e->Message ); - } -} - -int main() -{ - XmlReaderSettings^ booksSettings = gcnew XmlReaderSettings; - booksSettings->Schemas->Add( L"http://www.contoso.com/books", L"books.xsd" ); - booksSettings->ValidationType = ValidationType::Schema; - booksSettings->ValidationEventHandler += gcnew ValidationEventHandler( booksSettingsValidationEventHandler ); - XmlReader^ books = XmlReader::Create( L"books.xml", booksSettings ); - while ( books->Read() ) - {} - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.Credentials/CPP/secresolver2.cpp b/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.Credentials/CPP/secresolver2.cpp deleted file mode 100644 index ccf73e57aee..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.Credentials/CPP/secresolver2.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Net; -int main() -{ - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( "http://myServer/data/books.xml" ); - - // Create a secure resolver with default credentials. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - XmlSecureResolver^ sResolver = gcnew XmlSecureResolver( resolver,"http://myServer/data/" ); - sResolver->Credentials = CredentialCache::DefaultCredentials; - - // Use the secure resolver to resolve resources. - reader->XmlResolver = sResolver; - - // Parse the file. - while ( reader->Read() ) - { - - // Do any additional processing here. - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.cctor/CPP/secresolver.cpp b/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.cctor/CPP/secresolver.cpp deleted file mode 100644 index 3da4b5ed406..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.cctor/CPP/secresolver.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Security; -using namespace System::Security::Policy; -using namespace System::Net; - -// NOTE: To test, replace www.contoso.com w/ the local string - -// -Object^ GetFile( String^ fileURL, XmlResolver^ resolver ) -{ - // Generate the default PermissionSet using the file URL. - Evidence^ evidence = XmlSecureResolver::CreateEvidenceForUrl( fileURL ); - PermissionSet^ myPermissions = SecurityManager::ResolvePolicy( evidence ); - - // Modify the PermissionSet to only allow access to http://www.contoso.com. - // Create a WebPermission which only allows access to http://www.contoso.com. - WebPermission^ myWebPermission = gcnew WebPermission( - NetworkAccess::Connect,"http://www.contoso.com" ); - // Replace the existing WebPermission in myPermissions with the updated WebPermission. - myPermissions->SetPermission( myWebPermission ); - - // Use the modified PermissionSet to construct the XmlSecureResolver. - XmlSecureResolver^ sResolver = gcnew XmlSecureResolver( resolver,myPermissions ); - - // Get the object. - Uri^ fullUri = sResolver->ResolveUri( nullptr, fileURL ); - return sResolver->GetEntity( fullUri, nullptr, nullptr ); -} -// - -int main() -{ - Stream^ s = (Stream^)(GetFile( "http://localhost/data/books.xml", - gcnew XmlUrlResolver )); - XmlTextReader^ reader = gcnew XmlTextReader( s ); -} diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.Cctor/CPP/readfrag.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.Cctor/CPP/readfrag.cpp deleted file mode 100644 index 91be2b8ba6b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.Cctor/CPP/readfrag.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XML fragment to be parsed. - String^ xmlFrag = " Pride And Prejudice novel "; - - // Create the XmlNamespaceManager. - NameTable^ nt = gcnew NameTable; - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt ); - nsmgr->AddNamespace( "bk", "urn:sample" ); - - // Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::None ); - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - - // Parse the XML. If they exist, display the prefix and - // namespace URI of each element. - while ( reader->Read() ) - { - if ( reader->IsStartElement() ) - { - if ( reader->Prefix == String::Empty ) - Console::WriteLine( "< {0}>", reader->LocalName ); - else - { - Console::Write( "< {0}: {1}>", reader->Prefix, reader->LocalName ); - Console::WriteLine( " The namespace URI is {0}", reader->NamespaceURI ); - } - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp deleted file mode 100644 index 5ef9f82c8ce..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XML fragment to be parsed. - String^ xmlFrag = "\n" - "\n" - "\n" - "240\n" - "\n" - "\n"; - - // Create the XmlNamespaceManager. - NameTable^ nt = gcnew NameTable; - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt ); - - // Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::None ); - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - - // Parse the XML and display each node. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( " {0} {1}, {2} ", reader->Depth, reader->LineNumber, reader->LinePosition ); - Console::WriteLine( "< {0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( " {0} {1}, {2} ", reader->Depth, reader->LineNumber, reader->LinePosition ); - Console::WriteLine( " {0}", reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::Write( " {0} {1}, {2} ", reader->Depth, reader->LineNumber, reader->LinePosition ); - Console::WriteLine( "", reader->Name ); - break; - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.Normalization/CPP/readnormal.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.Normalization/CPP/readnormal.cpp deleted file mode 100644 index d7a782ca81e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.Normalization/CPP/readnormal.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XML fragment to be parsed. - String^ xmlFrag = "\n" - "\n"; - - // Create the XmlNamespaceManager. - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( gcnew NameTable ); - - // Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::Preserve ); - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - - // Show attribute value normalization. - reader->Read(); - reader->Normalization = false; - Console::WriteLine( "Attribute value: {0}", reader->GetAttribute( "attr1" ) ); - reader->Normalization = true; - Console::WriteLine( "Attribute value: {0}", reader->GetAttribute( "attr1" ) ); - - // Set Normalization back to false. This allows the reader to accept - // character entities in the � to  range. If Normalization had - // been set to true, character entities in this range throw an exception. - reader->Normalization = false; - reader->Read(); - reader->MoveToContent(); - Console::WriteLine( "Attribute value: {0}", reader->GetAttribute( "attr2" ) ); - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.ReadAttributeValue/CPP/readattrval.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.ReadAttributeValue/CPP/readattrval.cpp deleted file mode 100644 index 67a11857486..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.ReadAttributeValue/CPP/readattrval.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - __try - { - - // Create the XML fragment to be parsed. - String^ xmlFrag = ""; - - // Create the XmlParserContext. - XmlParserContext^ context; - String^ subset = ""; - context = gcnew XmlParserContext( nullptr,nullptr,"book",nullptr,nullptr,subset,"","",XmlSpace::None ); - - // Create the reader. - reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - - // Read the misc attribute. The attribute is parsed - // into multiple text and entity reference nodes. - reader->MoveToContent(); - reader->MoveToAttribute( "misc" ); - while ( reader->ReadAttributeValue() ) - { - if ( reader->NodeType == XmlNodeType::EntityReference ) - Console::WriteLine( " {0} {1}", reader->NodeType, reader->Name ); - else - Console::WriteLine( " {0} {1}", reader->NodeType, reader->Value ); - } - } - __finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.ResetState/CPP/resetstate.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.ResetState/CPP/resetstate.cpp deleted file mode 100644 index 43944b7d4c9..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.ResetState/CPP/resetstate.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -int main() -{ - Encoding^ enc = gcnew UTF8Encoding; - array^utf8Buffer = enc->GetBytes( " 12345 " ); - enc = gcnew UnicodeEncoding; - array^unicodeBuffer = enc->GetBytes( " root " ); - MemoryStream^ memStrm = gcnew MemoryStream; - memStrm->Write( unicodeBuffer, 0, unicodeBuffer->Length ); - memStrm->Write( utf8Buffer, 0, utf8Buffer->Length ); - memStrm->Position = 0; - XmlTextReader^ reader = gcnew XmlTextReader( memStrm ); - while ( reader->Read() ) - { - Console::WriteLine( "NodeType: {0}", reader->NodeType ); - if ( XmlNodeType::EndElement == reader->NodeType && "root" == reader->Name ) - break; - if ( XmlNodeType::EndElement == reader->NodeType ) - reader->ResetState(); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlLang/CPP/readlang.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlLang/CPP/readlang.cpp deleted file mode 100644 index baa5d62f323..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlLang/CPP/readlang.cpp +++ /dev/null @@ -1,50 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XML fragment to be parsed. - String^ xmlFrag = " Colour Analysis Color Analysis "; - - // Create the XmlNamespaceManager. - NameTable^ nt = gcnew NameTable; - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt ); - - // Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::None ); - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Parse the XML and display each of the nodes, including the xml:lang setting. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::WriteLine( "{0}: < {1}>", reader->XmlLang, reader->Name ); - break; - - case XmlNodeType::Text: - Console::WriteLine( "{0}: {1}", reader->XmlLang, reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::WriteLine( "{0}: ", reader->XmlLang, reader->Name ); - break; - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlResolver/CPP/rdr_resolver.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlResolver/CPP/rdr_resolver.cpp deleted file mode 100644 index dcc839cdab3..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlResolver/CPP/rdr_resolver.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Net; -int main() -{ - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( "http://myServer/data/books.xml" ); - - // Supply the credentials necessary to access the Web server. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - resolver->Credentials = CredentialCache::DefaultCredentials; - reader->XmlResolver = resolver; - - // Parse the file. - while ( reader->Read() ) - { - - // Do any additional processing here. - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlSpace/CPP/readspace.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlSpace/CPP/readspace.cpp deleted file mode 100644 index ae4be95667f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlSpace/CPP/readspace.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = gcnew XmlTextReader( "authors.xml" ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Parse the file. Return white space only if an - // xml:space='preserve' attribute is found. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( "<{0}>", reader->Name ); - if ( reader->XmlSpace == XmlSpace::Preserve ) - reader->WhitespaceHandling = WhitespaceHandling::Significant; - break; - - case XmlNodeType::Text: - Console::Write( reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::Write( "", reader->Name ); - break; - - case XmlNodeType::SignificantWhitespace: - Console::Write( reader->Value ); - break; - } - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.cctor1/CPP/rdrcctor1.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.cctor1/CPP/rdrcctor1.cpp deleted file mode 100644 index 32f5080e71f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.cctor1/CPP/rdrcctor1.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - String^ xmlData = "\r\n Oberon's Legacy\r\n 5.95\r\n "; - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( gcnew StringReader( xmlData ) ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Display each element node. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( "<{0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::Write( "", reader->Name ); - break; - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextWriter.Flush/CPP/write2docs.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextWriter.Flush/CPP/write2docs.cpp deleted file mode 100644 index 7457e02c9e8..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextWriter.Flush/CPP/write2docs.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - - // Use indenting for readability - writer->Formatting = Formatting::Indented; - - // Write an XML fragment. - writer->WriteStartElement( "book" ); - writer->WriteElementString( "title", "Pride And Prejudice" ); - writer->WriteEndElement(); - writer->Flush(); - - // Write another XML fragment. - writer->WriteStartElement( "cd" ); - writer->WriteElementString( "title", "Americana" ); - writer->WriteEndElement(); - writer->Flush(); - - // Close the writer. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp deleted file mode 100644 index ff9fd542be2..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create a writer to write XML to the console. - XmlWriterSettings^ settings = gcnew XmlWriterSettings; - settings->Indent = true; - settings->OmitXmlDeclaration = true; - XmlWriter^ writer = XmlWriter::Create( Console::Out, settings ); - - // Write the book element. - writer->WriteStartElement( L"book" ); - - // Write the title element. - writer->WriteStartElement( L"title" ); - writer->WriteString( L"Pride And Prejudice" ); - writer->WriteEndElement(); - - // Write the close tag for the root element. - writer->WriteEndElement(); - - // Write the XML and close the writer. - writer->Close(); - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.Flush/CPP/write2docs_v2.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.Flush/CPP/write2docs_v2.cpp deleted file mode 100644 index ca3bcbf4373..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.Flush/CPP/write2docs_v2.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -void main() -{ - - // Create an XmlWriter to write XML fragments. - XmlWriterSettings^ settings = gcnew XmlWriterSettings; - settings->ConformanceLevel = ConformanceLevel::Fragment; - settings->Indent = true; - XmlWriter^ writer = XmlWriter::Create( Console::Out, settings ); - - // Write an XML fragment. - writer->WriteStartElement( L"book" ); - writer->WriteElementString( L"title", L"Pride And Prejudice" ); - writer->WriteEndElement(); - writer->Flush(); - - // Write another XML fragment. - writer->WriteStartElement( L"cd" ); - writer->WriteElementString( L"title", L"Americana" ); - writer->WriteEndElement(); - writer->Flush(); - - // Close the writer. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributeString/CPP/writeattrstring.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributeString/CPP/writeattrstring.cpp deleted file mode 100644 index 59b7bac475a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributeString/CPP/writeattrstring.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -void main() -{ - XmlWriter^ writer = nullptr; - writer = XmlWriter::Create( L"sampledata.xml" ); - - // Write the root element. - writer->WriteStartElement( L"book" ); - - // Write the xmlns:bk="urn:book" namespace declaration. - writer->WriteAttributeString( L"xmlns", L"bk", nullptr, L"urn:book" ); - - // Write the bk:ISBN="1-800-925" attribute. - writer->WriteAttributeString( L"ISBN", L"urn:book", L"1-800-925" ); - writer->WriteElementString( L"price", L"19.95" ); - - // Write the close tag for the root element. - writer->WriteEndElement(); - - // Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributes/CPP/writeattrs_v2.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributes/CPP/writeattrs_v2.cpp deleted file mode 100644 index cd4481a5f86..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributes/CPP/writeattrs_v2.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -void main() -{ - XmlReader^ reader = XmlReader::Create( L"test1.xml" ); - XmlWriterSettings^ settings = gcnew XmlWriterSettings; - settings->Indent = true; - XmlWriter^ writer = XmlWriter::Create( Console::Out ); - while ( reader->Read() ) - { - if ( reader->NodeType == XmlNodeType::Element ) - { - writer->WriteStartElement( reader->Name->ToUpper() ); - writer->WriteAttributes( reader, false ); - if ( reader->IsEmptyElement ) - writer->WriteEndElement(); - } - else - if ( reader->NodeType == XmlNodeType::EndElement ) - { - writer->WriteEndElement(); - } - } - - writer->Close(); - reader->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteBase64/CPP/writebase64.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteBase64/CPP/writebase64.cpp deleted file mode 100644 index af773508941..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteBase64/CPP/writebase64.cpp +++ /dev/null @@ -1,143 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Text; -ref class TestBase64 -{ -private: - static int bufferSize = 4096; - -public: - - // Use the WriteBase64 method to create an XML document. The object - // passed by the user is encoded and included in the document. - void EncodeXmlFile( String^ xmlFileName, FileStream^ fileOld ) - { - array^buffer = gcnew array(bufferSize); - int readByte = 0; - XmlTextWriter^ xw = gcnew XmlTextWriter( xmlFileName,Encoding::UTF8 ); - xw->WriteStartDocument(); - xw->WriteStartElement( "root" ); - - // Create a Char writer. - BinaryReader^ br = gcnew BinaryReader( fileOld ); - - // Set the file pointer to the end. - try - { - do - { - readByte = br->Read( buffer, 0, bufferSize ); - xw->WriteBase64( buffer, 0, readByte ); - } - while ( bufferSize <= readByte ); - } - catch ( Exception^ ex ) - { - EndOfStreamException^ ex1 = gcnew EndOfStreamException; - if ( ex1->Equals( ex ) ) - Console::WriteLine( "We are at end of file" ); - else - Console::WriteLine( ex ); - } - - xw->WriteEndElement(); - xw->WriteEndDocument(); - xw->Flush(); - xw->Close(); - } - - // Use the ReadBase64 method to decode the new XML document - // and generate the original object. - void DecodeOrignalObject( String^ xmlFileName, FileStream^ fileNew ) - { - array^buffer = gcnew array(bufferSize); - int readByte = 0; - - // Create a file to write the bmp back. - BinaryWriter^ bw = gcnew BinaryWriter( fileNew ); - XmlTextReader^ tr = gcnew XmlTextReader( xmlFileName ); - tr->MoveToContent(); - Console::WriteLine( tr->Name ); - do - { - readByte = tr->ReadBase64( buffer, 0, bufferSize ); - bw->Write( buffer, 0, readByte ); - } - while ( readByte >= bufferSize ); - - bw->Flush(); - } - - // Compare the two files. - bool CompareResult( FileStream^ fileOld, FileStream^ fileNew ) - { - int readByteOld = 0; - int readByteNew = 0; - int count; - int readByte = 0; - array^bufferOld = gcnew array(bufferSize); - array^bufferNew = gcnew array(bufferSize); - BinaryReader^ binaryReaderOld = gcnew BinaryReader( fileOld ); - BinaryReader^ binaryReaderNew = gcnew BinaryReader( fileNew ); - binaryReaderOld->BaseStream->Seek( 0, SeekOrigin::Begin ); - binaryReaderNew->BaseStream->Seek( 0, SeekOrigin::Begin ); - do - { - readByteOld = binaryReaderOld->Read( bufferOld, 0, bufferSize ); - readByteNew = binaryReaderNew->Read( bufferNew, 0, bufferSize ); - if ( readByteOld != readByteNew ) - return false; - - for ( count = 0; count < bufferSize; ++count ) - if ( bufferOld[ count ] != bufferNew[ count ] ) - return false; - } - while ( count < readByte ); - - return true; - } - - // Display the usage statement. - void Usage() - { - Console::WriteLine( "TestBase64 sourceFile, targetFile \n" ); - Console::WriteLine( "For example: TestBase64 winlogon.bmp, target.bmp\n" ); - } -}; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - TestBase64^ testBase64 = gcnew TestBase64; - - // Check that the usage is correct. - if ( args->Length < 3 ) - { - testBase64->Usage(); - return 1; - } - - FileStream^ fileOld = gcnew FileStream( args[ 1 ],FileMode::OpenOrCreate,FileAccess::Read,FileShare::Read ); - testBase64->EncodeXmlFile( "temp.xml", fileOld ); - FileStream^ fileNew = gcnew FileStream( args[ 2 ],FileMode::Create,FileAccess::ReadWrite,FileShare::ReadWrite ); - testBase64->DecodeOrignalObject( "temp.xml", fileNew ); - - // Compare the two files. - if ( testBase64->CompareResult( fileOld, fileNew ) ) - Console::WriteLine( "The recreated binary file {0} is the same as {1}", args[ 2 ], args[ 1 ] ); - else - Console::WriteLine( "The recreated binary file {0} is not the same as {1}", args[ 2 ], args[ 1 ] ); - - fileOld->Flush(); - fileNew->Flush(); - fileOld->Close(); - fileNew->Close(); - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp deleted file mode 100644 index 1b8726a4f19..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -private: - static String^ m_Document = L"sampledata.xml"; - -public: - static void Main() - { - XmlWriter^ writer = nullptr; - try - { - XmlWriterSettings^ settings = gcnew XmlWriterSettings; - settings->Indent = true; - writer = XmlWriter::Create( m_Document,settings ); - writer->WriteComment( L"sample XML fragment" ); - - // Write an element (this one is the root). - writer->WriteStartElement( L"book" ); - - // Write the namespace declaration. - writer->WriteAttributeString( L"xmlns", L"bk", nullptr, L"urn:samples" ); - - // Write the genre attribute. - writer->WriteAttributeString( L"genre", L"novel" ); - - // Write the title. - writer->WriteStartElement( L"title" ); - writer->WriteString( L"The Handmaid's Tale" ); - writer->WriteEndElement(); - - // Write the price. - writer->WriteElementString( L"price", L"19.95" ); - - // Lookup the prefix and write the ISBN element. - String^ prefix = writer->LookupPrefix( L"urn:samples" ); - writer->WriteStartElement( prefix, L"ISBN", L"urn:samples" ); - writer->WriteString( L"1-861003-78" ); - writer->WriteEndElement(); - - // Write the style element (shows a different way to handle prefixes). - writer->WriteElementString( L"style", L"urn:samples", L"hardcover" ); - - // Write the close tag for the root element. - writer->WriteEndElement(); - - // Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); - } - finally - { - if ( writer != nullptr ) - writer->Close(); - } - - } - -}; - -void main() -{ - Sample::Main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteNode/CPP/writenode.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteNode/CPP/writenode.cpp deleted file mode 100644 index a34c595c6da..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteNode/CPP/writenode.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = gcnew XmlTextReader( "books.xml" ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Move the reader to the first book element. - reader->MoveToContent(); - reader->Read(); - - // Create a writer that outputs to the console. - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - - // Write the start tag. - writer->WriteStartElement( "myBooks" ); - - // Write the first book. - writer->WriteNode( reader, false ); - - // Skip the second book. - reader->Skip(); - - // Write the last book. - writer->WriteNode( reader, false ); - writer->WriteEndElement(); - - // Close the writer and the reader. - writer->Close(); - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XslTRansform.Transform7/CPP/trans_snip4.cpp b/snippets/cpp/VS_Snippets_Data/XslTRansform.Transform7/CPP/trans_snip4.cpp deleted file mode 100644 index c26844cce27..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XslTRansform.Transform7/CPP/trans_snip4.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; - -int main() -{ - // - // Create a resolver with default credentials. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - resolver->Credentials = System::Net::CredentialCache::DefaultCredentials; - - // Create the XslTransform object. - XslTransform^ xslt = gcnew XslTransform; - - // Load the stylesheet. - xslt->Load( "http://myServer/data/authors.xsl", resolver ); - - // Transform the file. - xslt->Transform( "books.xml", "books.html", resolver ); - // -} diff --git a/snippets/cpp/VS_Snippets_Data/XslTransform.Load3/CPP/trans3.cpp b/snippets/cpp/VS_Snippets_Data/XslTransform.Load3/CPP/trans3.cpp deleted file mode 100644 index c1c69b21c5d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XslTransform.Load3/CPP/trans3.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; -int main() -{ - String^ filename = "books.xml"; - String^ stylesheet = "titles.xsl"; - - // Create the reader to load the stylesheet. - // Move the reader to the xsl:stylesheet node. - XmlTextReader^ reader = gcnew XmlTextReader( stylesheet ); - reader->Read(); - reader->Read(); - - // Create the XslTransform object and load the stylesheet. - XslTransform^ xslt = gcnew XslTransform; - xslt->Load( reader ); - - // Load the file to transform. - XPathDocument^ doc = gcnew XPathDocument( filename ); - - // Create an XmlTextWriter which outputs to the console. - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - - // Transform the file and send the output to the console. - xslt->Transform(doc,nullptr,writer); - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XslTransform.Load4/CPP/trans_ev.cpp b/snippets/cpp/VS_Snippets_Data/XslTransform.Load4/CPP/trans_ev.cpp deleted file mode 100644 index 589fa928b67..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XslTransform.Load4/CPP/trans_ev.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; -void TransformFile( XmlReader^ xsltReader, String^ secureURL ); -int main() -{ - String^ stylesheet = "c:\\tmp\\output.xsl"; - String^ myURL = "http://localhost/data"; - XmlTextReader^ reader = gcnew XmlTextReader( stylesheet ); - TransformFile( reader, myURL ); -} - - -// Perform an XSLT transformation where xsltReader is an XmlReader containing -// a stylesheet and secureURI is a trusted URI that can be used to create Evidence. -// -void TransformFile( XmlReader^ xsltReader, String^ secureURL ) -{ - - // Load the stylesheet using a default XmlUrlResolver and Evidence - // created using the trusted URL. - XslTransform^ xslt = gcnew XslTransform; - xslt->Load( xsltReader, gcnew XmlUrlResolver, XmlSecureResolver::CreateEvidenceForUrl( secureURL ) ); - - // Transform the file. - xslt->Transform("books.xml","books.html",gcnew XmlUrlResolver); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XslTransform.Transform2/CPP/trans_snip.cpp b/snippets/cpp/VS_Snippets_Data/XslTransform.Transform2/CPP/trans_snip.cpp deleted file mode 100644 index 4b4ca81384f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XslTransform.Transform2/CPP/trans_snip.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; - -int main() -{ -// - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - - // Modify the XML file. - XmlElement^ root = doc->DocumentElement; - root->FirstChild->LastChild->InnerText = "12.95"; - - // Create an XPathNavigator to use for the transform. - XPathNavigator^ nav = root->CreateNavigator(); - - // Transform the file. - XslTransform^ xslt = gcnew XslTransform; - xslt->Load( "output.xsl" ); - XmlTextWriter^ writer = gcnew XmlTextWriter( "books.html", nullptr ); - xslt->Transform( nav, nullptr, writer, nullptr); -// -} diff --git a/snippets/cpp/VS_Snippets_Data/XslTransform.Transform4/CPP/trans_snip3.cpp b/snippets/cpp/VS_Snippets_Data/XslTransform.Transform4/CPP/trans_snip3.cpp deleted file mode 100644 index 93872c9a3c6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XslTransform.Transform4/CPP/trans_snip3.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - String^ UserName = args[ 1 ]; - String^ SecurelyStoredPassword = args[ 2 ]; - String^ Domain = args[ 3 ]; - - // - // Create the XslTransform object. - XslTransform^ xslt = gcnew XslTransform; - - // Load the stylesheet. - xslt->Load( "titles.xsl" ); - - // Create a resolver and specify the necessary credentials. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - System::Net::NetworkCredential^ myCred; - myCred = gcnew System::Net::NetworkCredential( UserName, SecurelyStoredPassword, Domain ); - resolver->Credentials = myCred; - - // Transform the file using the resolver. The resolver is used - // to process the XSLT document() function. - XPathDocument^ doc = gcnew XPathDocument( "books.xml" ); - XmlReader^ reader = xslt->Transform( doc, nullptr, resolver ); - - // Load the reader into a new document for more processing. - XmlDocument^ xmldoc = gcnew XmlDocument; - xmldoc->Load( reader ); - // - - Console::WriteLine( xmldoc->OuterXml ); -} diff --git a/snippets/cpp/VS_Snippets_Data/xsltransform.transform3/CPP/trans_snip2.cpp b/snippets/cpp/VS_Snippets_Data/xsltransform.transform3/CPP/trans_snip2.cpp deleted file mode 100644 index 326d279b9ae..00000000000 --- a/snippets/cpp/VS_Snippets_Data/xsltransform.transform3/CPP/trans_snip2.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; - -int main() -{ - // - // Create the XslTransform object. - XslTransform^ xslt = gcnew XslTransform; - - // Load the stylesheet. - xslt->Load( "output.xsl" ); - - // Transform the file. - xslt->Transform("books.xml","books.html"); - // -} diff --git a/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange/cpp/source.cpp b/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange/cpp/source.cpp deleted file mode 100644 index df2c6373e93..00000000000 --- a/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange/cpp/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*System::Net::HttpWebRequest->AddRange(int, int) -This program demonstrates 'AddRange(int, int)' method of 'HttpWebRequest class. -A new 'HttpWebRequest' Object* is created. The number of characters of the response to be received can be -restricted by the 'AddRange' method.By calling 'AddRange(50, 150)' on the 'HttpWebRequest' Object* the content -of the response page is restricted from the 50th character to 150th charater. The response of the request is -obtained and displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -int main() -{ - try - { -// - // Create a New 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest1 = - (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest1->AddRange( 1000); - Console::WriteLine("Call AddRange(1000)"); - Console::Write("Resulting Headers: "); - Console::WriteLine(myHttpWebRequest1->Headers); - - HttpWebRequest^ myHttpWebRequest2 = - (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest2->AddRange(-1000); - Console::WriteLine("Call AddRange(-1000)"); - Console::Write("Resulting Headers: "); - Console::WriteLine(myHttpWebRequest2->Headers); - -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/cpp/source.cpp b/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/cpp/source.cpp deleted file mode 100644 index 68d09127497..00000000000 --- a/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/cpp/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*System::Net::HttpWebRequest->AddRange(int, int) -This program demonstrates 'AddRange(int, int)' method of 'HttpWebRequest class. -A new 'HttpWebRequest' Object* is created. The number of characters of the response to be received can be -restricted by the 'AddRange' method.By calling 'AddRange(50, 150)' on the 'HttpWebRequest' Object* the content -of the response page is restricted from the 50th character to 150th charater. The response of the request is -obtained and displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -int main() -{ - try - { -// - // Create a New 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest->AddRange( 50, 150 ); - Console::WriteLine("Call AddRange(50, 150)"); - Console::Write("Resulting Request Headers: "); - Console::WriteLine(myHttpWebRequest->Headers); - - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - - // Displays the headers in the response received - Console::Write("Resulting Response Headers: "); - Console::WriteLine(myHttpWebResponse->Headers); - - // Display the contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuffer = gcnew array(256); - int count = streamRead->Read( readBuffer, 0, 256 ); - Console::WriteLine( "\nThe HTML contents of the page from 50th to 150 charaters are :\n " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuffer,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuffer, 0, 256 ); - } - streamRead->Close(); - streamResponse->Close(); - myHttpWebResponse->Close(); -// - Console::WriteLine( "\nPress 'Enter' Key to Continue..........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp deleted file mode 100644 index 557ea7d00c8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class XClass -{ -public: - - /* Apply the XmlAnyElementAttribute to a field returning an array - of XmlElement objects. */ - - [XmlAnyElement] - array^AllElements; -}; - -public ref class Test -{ -public: - void DeserializeObject( String^ filename ) - { - // Create an XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( XClass::typeid ); - - // To read a file, a FileStream is needed. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Deserialize the class. - XClass^ x = dynamic_cast(mySerializer->Deserialize( fs )); - - // Read the element names and values. - System::Collections::IEnumerator^ myEnum = x->AllElements->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlElement^ xel = safe_cast(myEnum->Current); - Console::WriteLine( "{0}: {1}", xel->LocalName, xel->Value ); - } - } -}; - -int main() -{ - Test^ t = gcnew Test; - t->DeserializeObject( "XFile.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp deleted file mode 100644 index 7824f3ba5cb..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,132 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -public ref class Item -{ -public: - - [XmlElement(ElementName="OrderItem")] - String^ ItemName; - String^ ItemCode; - Decimal ItemPrice; - int ItemQuantity; -}; - -public ref class BookItem: public Item -{ -public: - String^ Title; - String^ Author; - String^ ISBN; -}; - -// This is the class that will be serialized. -public ref class MyRootClass -{ -private: - array^items; - -public: - - /* Here is a simple way to serialize the array as XML. Using the - XmlArrayAttribute, assign an element name and namespace. The - IsNullable property determines whether the element will be - generated if the field is set to a null value. If set to true, - the default, setting it to a null value will cause the XML - xsi:null attribute to be generated. */ - - [XmlArray(ElementName="MyStrings", - Namespace="http://www.cpandl.com",IsNullable=true)] - array^MyStringArray; - - /* Here is a more complex example of applying an - XmlArrayAttribute. The Items property can contain both Item - and BookItem objects. Use the XmlArrayItemAttribute to specify - that both types can be inserted into the array. */ - [XmlArrayItem(ElementName="Item", - IsNullable=true, - Type=Item::typeid, - Namespace="http://www.cpandl.com"), - XmlArrayItem(ElementName="BookItem", - IsNullable=true, - Type=BookItem::typeid, - Namespace="http://www.cohowinery.com")] - [XmlArray] - property array^ Items - { - array^ get() - { - return items; - } - - void set( array^value ) - { - items = value; - } - } -}; - -public ref class Run -{ -public: - void SerializeDocument( String^ filename ) - { - // Creates a new XmlSerializer. - XmlSerializer^ s = gcnew XmlSerializer( MyRootClass::typeid ); - - // Writing the file requires a StreamWriter. - TextWriter^ myWriter = gcnew StreamWriter( filename ); - - // Creates an instance of the class to serialize. - MyRootClass^ myRootClass = gcnew MyRootClass; - - /* Uses a basic method of creating an XML array: Create and - populate a string array, and assign it to the - MyStringArray property. */ - array^myString = {"Hello","world","!"}; - myRootClass->MyStringArray = myString; - - /* Uses a more advanced method of creating an array: - create instances of the Item and BookItem, where BookItem - is derived from Item. */ - Item^ item1 = gcnew Item; - BookItem^ item2 = gcnew BookItem; - - // Sets the objects' properties. - item1->ItemName = "Widget1"; - item1->ItemCode = "w1"; - item1->ItemPrice = 231; - item1->ItemQuantity = 3; - item2->ItemCode = "w2"; - item2->ItemPrice = 123; - item2->ItemQuantity = 7; - item2->ISBN = "34982333"; - item2->Title = "Book of Widgets"; - item2->Author = "John Smith"; - - // Fills the array with the items. - array^myItems = {item1,item2}; - - // Sets the class's Items property to the array. - myRootClass->Items = myItems; - - /* Serializes the class, writes it to disk, and closes - the TextWriter. */ - s->Serialize( myWriter, myRootClass ); - myWriter->Close(); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeDocument( "books.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp deleted file mode 100644 index dc6cfc478ab..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Book -{ -public: - String^ Title; - String^ Author; - String^ ISBN; -}; - -public ref class Library -{ -private: - array^books; - -public: - - [XmlArray(ElementName="My_Books")] - property array^ Books - { - array^ get() - { - return books; - } - - void set( array^value ) - { - books = value; - } - } -}; - -int main() -{ - String^ filename = "ArrayExample.xml"; - XmlSerializer^ mySerializer = gcnew XmlSerializer( Library::typeid ); - TextWriter^ t = gcnew StreamWriter( filename ); - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - ns->Add( "bk", "http://wwww.contoso.com" ); - Book^ b1 = gcnew Book; - b1->Title = "MyBook Title"; - b1->Author = "An Author"; - b1->ISBN = "00000000"; - Book^ b2 = gcnew Book; - b2->Title = "Another Title"; - b2->Author = "Another Author"; - b2->ISBN = "0000000"; - Library^ myLibrary = gcnew Library; - array^myBooks = {b1,b2}; - myLibrary->Books = myBooks; - mySerializer->Serialize( t, myLibrary, ns ); - t->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 84965bcbf7a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,111 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; -public ref class Winery -{ -public: - String^ Name; -}; - -public ref class VacationCompany -{ -public: - String^ Name; -}; - -public ref class Enterprises -{ -private: - array^wineries; - array^companies; - -public: - - // Sets the Form property to qualified, and specifies the namespace. - [XmlArray(Form=XmlSchemaForm::Qualified,ElementName="Company", - Namespace="http://www.cohowinery.com")] - property array^ Wineries - { - array^ get() - { - return wineries; - } - void set( array^value ) - { - wineries = value; - } - } - - [XmlArray(Form=XmlSchemaForm::Qualified,ElementName="Company", - Namespace="http://www.treyresearch.com")] - property array^ Companies - { - array^ get() - { - return companies; - } - void set( array^value ) - { - companies = value; - } - } -}; - -int main() -{ - String^ filename = "MyEnterprises.xml"; - - // Creates an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Enterprises::typeid ); - - // Writing file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Creates an instance of the XmlSerializerNamespaces class. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Adds namespaces and prefixes for the XML document instance. - ns->Add( "winery", "http://www.cohowinery.com" ); - ns->Add( "vacationCompany", "http://www.treyresearch.com" ); - - // Creates an instance of the class that will be serialized. - Enterprises^ myEnterprises = gcnew Enterprises; - - // Creates objects and adds to the array. - Winery^ w1 = gcnew Winery; - w1->Name = "cohowinery"; - array^myWinery = {w1}; - myEnterprises->Wineries = myWinery; - VacationCompany^ com1 = gcnew VacationCompany; - com1->Name = "adventure-works"; - array^myCompany = {com1}; - myEnterprises->Companies = myCompany; - - // Serializes the class, and closes the TextWriter. - mySerializer->Serialize( writer, myEnterprises, ns ); - writer->Close(); -} - -void ReadEnterprises( String^ filename ) -{ - XmlSerializer^ mySerializer = gcnew XmlSerializer( Enterprises::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Enterprises^ myEnterprises = dynamic_cast(mySerializer->Deserialize( fs )); - for ( int i = 0; i < myEnterprises->Wineries->Length; i++ ) - { - Console::WriteLine( myEnterprises->Wineries[ i ]->Name ); - } - for ( int i = 0; i < myEnterprises->Companies->Length; i++ ) - { - Console::WriteLine( myEnterprises->Companies[ i ]->Name ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index b04f9de845e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlArray(IsNullable=true)] - array^IsNullableIsTrueArray; - - [XmlArray(IsNullable=false)] - array^IsNullableIsFalseArray; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index ffc20656b48..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,162 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Book -{ -public: - String^ Title; - String^ Author; - String^ ISBN; - - [XmlAttributeAttribute] - String^ Publisher; -}; - -public ref class Periodical -{ -private: - String^ title; - -public: - - property String^ Title - { - String^ get() - { - return title; - } - void set( String^ value ) - { - title = value; - } - } -}; - -public ref class Library -{ -private: - array^books; - array^periodicals; - -public: - - /* This element will be qualified with the prefix - that is associated with the namespace http://wwww.cpandl.com. */ - [XmlArray(ElementName="Titles", - Namespace="http://wwww.cpandl.com")] - property array^ Books - { - array^ get() - { - return books; - } - void set( array^value ) - { - books = value; - } - } - - /* This element will be qualified with the prefix that is - associated with the namespace http://www.proseware.com. */ - [XmlArray(ElementName="Titles",Namespace= - "http://www.proseware.com")] - property array^ Periodicals - { - array^ get() - { - return periodicals; - } - void set( array^value ) - { - periodicals = value; - } - } -}; - -void WriteBook( String^ filename ) -{ - // Creates a new XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Library::typeid ); - - // Writing the file requires a StreamWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - /* Creates an XmlSerializerNamespaces and adds prefixes and - namespaces to be used. */ - XmlSerializerNamespaces^ myNamespaces = gcnew XmlSerializerNamespaces; - myNamespaces->Add( "books", "http://wwww.cpandl.com" ); - myNamespaces->Add( "magazines", "http://www.proseware.com" ); - - // Creates an instance of the class to be serialized. - Library^ myLibrary = gcnew Library; - - // Creates two book objects. - Book^ b1 = gcnew Book; - b1->Title = "My Book Title"; - b1->Author = "An Author"; - b1->ISBN = "000000000"; - b1->Publisher = "Microsoft Press"; - Book^ b2 = gcnew Book; - b2->Title = "Another Book Title"; - b2->Author = "Another Author"; - b2->ISBN = "00000001"; - b2->Publisher = "Another Press"; - - /* Creates an array using the objects, and sets the Books property - to the array. */ - array^myBooks = {b1,b2}; - myLibrary->Books = myBooks; - - // Creates two Periodical objects. - Periodical^ per1 = gcnew Periodical; - per1->Title = "My Magazine Title"; - Periodical^ per2 = gcnew Periodical; - per2->Title = "Another Magazine Title"; - - // Sets the Periodicals property to the array. - array^myPeridocials = {per1,per2}; - myLibrary->Periodicals = myPeridocials; - - // Serializes the myLibrary object. - mySerializer->Serialize( myStreamWriter, myLibrary, myNamespaces ); - myStreamWriter->Close(); -} - -void ReadBook( String^ filename ) -{ - /* Creates an instance of an XmlSerializer - with the class used to read the document. */ - XmlSerializer^ mySerializer = gcnew XmlSerializer( Library::typeid ); - - // A FileStream is needed to read the file. - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Library^ myLibrary = dynamic_cast(mySerializer->Deserialize( myFileStream )); - - // Reads each book in the array returned by the Books property. - for ( int i = 0; i < myLibrary->Books->Length; i++ ) - { - Console::WriteLine( myLibrary->Books[ i ]->Title ); - Console::WriteLine( myLibrary->Books[ i ]->Author ); - Console::WriteLine( myLibrary->Books[ i ]->ISBN ); - Console::WriteLine( myLibrary->Books[ i ]->Publisher ); - Console::WriteLine(); - } - for ( int i = 0; i < myLibrary->Periodicals->Length; i++ ) - { - Console::WriteLine( myLibrary->Periodicals[ i ]->Title ); - } -} - -int main() -{ - WriteBook( "MyLibrary.xml" ); - ReadBook( "MyLibrary.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp deleted file mode 100644 index 78a6040f3fa..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlArrayAttribute] - array^MyStringArray; - - [XmlArrayAttribute] - array^MyIntegerArray; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp deleted file mode 100644 index 9b68919eff8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class MyClass -{ -public: - - [XmlArrayAttribute("MyStrings")] - array^MyStringArray; - - [XmlArrayAttribute(ElementName="MyIntegers")] - array^MyIntegerArray; -}; - -int main() -{ - String^ filename = "MyClass.xml"; - - // Creates a new instance of the XmlSerializer class. - XmlSerializer^ s = gcnew XmlSerializer( MyClass::typeid ); - - // Needs a StreamWriter to write the file. - TextWriter^ myWriter = gcnew StreamWriter( filename ); - MyClass^ myClass = gcnew MyClass; - - // Creates and populates a string array, then assigns - // it to the MyStringArray property. - array^myStrings = {"Hello","World","!"}; - myClass->MyStringArray = myStrings; - - /* Creates and populates an integer array, and assigns - it to the MyIntegerArray property. */ - array^myIntegers = {1,2,3}; - myClass->MyIntegerArray = myIntegers; - - // Serializes the class, and writes it to disk. - s->Serialize( myWriter, myClass ); - myWriter->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp deleted file mode 100644 index 7504aad63a3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,93 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - /* The XmlArrayItemAttribute allows the XmlSerializer to insert - both the base type (Employee) and derived type (Manager) - into serialized arrays. */ - - [XmlArrayItem(Manager::typeid), - XmlArrayItem(Employee::typeid)] - array^Employees; - - /* Use the XmlArrayItemAttribute to specify types allowed - in an array of Object items. */ - - [XmlArray] - [XmlArrayItem(Int32::typeid, - ElementName="MyNumber"), - XmlArrayItem(String::typeid, - ElementName="MyString"), - XmlArrayItem(Manager::typeid)] - array^ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // Creates a new XmlSerializer. - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - Group^ group = gcnew Group; - Manager^ manager = gcnew Manager; - Employee^ emp1 = gcnew Employee; - Employee^ emp2 = gcnew Employee; - manager->Name = "Consuela"; - manager->Level = 3; - emp1->Name = "Seiko"; - emp2->Name = "Martina"; - array^emps = {manager,emp1,emp2}; - group->Employees = emps; - - // Creates an int and a string and assigns to ExtraInfo. - array^temp = {43,"Extra",manager}; - group->ExtraInfo = temp; - - // Serializes the object, and closes the StreamWriter. - s->Serialize( writer, group ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlSerializer^ x = gcnew XmlSerializer( Group::typeid ); - Group^ g = dynamic_cast(x->Deserialize( fs )); - Console::WriteLine( "Members:" ); - System::Collections::IEnumerator^ myEnum = g->Employees->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Employee^ e = safe_cast(myEnum->Current); - Console::WriteLine( "\t{0}", e->Name ); - } -} - -int main() -{ - SerializeObject( "TypeDoc.xml" ); - DeserializeObject( "TypeDoc.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp deleted file mode 100644 index 1ad1f494f35..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// By default, this class results in XML elements named "Vehicle". -public ref class Vehicle -{ -public: - String^ id; -}; - -// By default, this class results in XML elements named "Car". -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - /* Specifies acceptable types and the ElementName generated - for each object type. */ - - [XmlArray("Vehicles")] - [XmlArrayItem(Vehicle::typeid,ElementName="Transport"), - XmlArrayItem(Car::typeid,ElementName="Automobile")] - array^MyVehicles; -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 6f0101ea001..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -// -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - // Specifies the Form property value. - - [XmlArray("Vehicles")] - [XmlArrayItem(Vehicle::typeid, - Form=XmlSchemaForm::Unqualified), - XmlArrayItem(Car::typeid, - Form=XmlSchemaForm::Qualified)] - array^MyVehicles; -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index 10b3c35b2f1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - [XmlArray(IsNullable=true)] - [XmlArrayItem(Manager::typeid,IsNullable=false), - XmlArrayItem(Employee::typeid,IsNullable=false)] - array^Employees; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Creates the object to serialize. - Group^ group = gcnew Group; - - // Creates a null Manager object. - Manager^ mgr = nullptr; - - // Creates a null Employee object. - Employee^ y = nullptr; - array^temp = {mgr,y}; - group->Employees = temp; - - // Serializes the object and closes the TextWriter. - s->Serialize( writer, group ); - writer->Close(); -} - -int main() -{ - SerializeObject( "TypeDoc.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 41cc05bd344..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Vehicle{}; - -public ref class Car: public Vehicle{}; - -// -public ref class Transportation -{ -public: - - // Sets the Namespace property. - - [XmlArrayItem(Car::typeid,Namespace="http://www.cpandl.com")] - array^MyVehicles; -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp deleted file mode 100644 index b249fa9707c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Person -{ -public: - String^ Name; -}; - -public ref class Manager: public Person -{ -public: - int Rank; -}; - -public ref class Group -{ -public: - - /* The Type property instructs the XmlSerializer to accept both - the Person and Manager types in the array. */ - - [XmlArrayItem(Type=Manager::typeid), - XmlArrayItem(Type=Person::typeid)] - array^Staff; -}; - -void SerializeOrder( String^ filename ) -{ - // Creates an XmlSerializer. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid ); - - // Creates the Group object, and two array items. - Group^ myGroup = gcnew Group; - Person^ p1 = gcnew Person; - p1->Name = "Jacki"; - Manager^ p2 = gcnew Manager; - p2->Name = "Megan"; - p2->Rank = 2; - array^myStaff = {p1,p2}; - myGroup->Staff = myStaff; - - // Serializes the object, and closes the StreamWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myGroup ); -} - -int main() -{ - SerializeOrder( "TypeEx.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp deleted file mode 100644 index 153e7b6e3d2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArrayItem, - XmlArrayItem(Car::typeid,ElementName="Automobile")] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer for the Transportation class. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - - // Creates the object to serialize. - Transportation^ myTransportation = gcnew Transportation; - - // Creates objects to add to the array. - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^temp = {myVehicle,myCar}; - myTransportation->MyVehicles = temp; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates an XmlSerializer instance. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem1.xml" ); - DeserializeObject( "XmlArrayItem1.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp deleted file mode 100644 index 27560a12758..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArrayItem(ElementName="Transportation"), - XmlArrayItem(Car::typeid,ElementName="Automobile")] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer for the Transportation class. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - Transportation^ myTransportation = gcnew Transportation; - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^myVehicles = {myVehicle,myCar}; - myTransportation->MyVehicles = myVehicles; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates the serializer with the type to deserialize. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem2.xml" ); - DeserializeObject( "XmlArrayItem2.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp deleted file mode 100644 index 8809b40c0af..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArrayItem(Vehicle::typeid), - XmlArrayItem(Car::typeid)] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - Transportation^ myTransportation = gcnew Transportation; - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^myVehicles = {myVehicle,myCar}; - myTransportation->MyVehicles = myVehicles; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates the serializer with the type to deserialize. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem3.xml" ); - DeserializeObject( "XmlArrayItem3.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp deleted file mode 100644 index 6886a80fe91..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArray] - [XmlArrayItem("Transport",Vehicle::typeid), - XmlArrayItem("Automobile",Car::typeid)] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer for the Transportation class. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - Transportation^ myTransportation = gcnew Transportation; - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^myVehicles = {myVehicle,myCar}; - myTransportation->MyVehicles = myVehicles; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates an XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem4.xml" ); - DeserializeObject( "XmlArrayItem4.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp deleted file mode 100644 index ded3d3f240a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - - [XmlAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; - - [XmlAttributeAttribute(DataType="base64Binary")] - array^GroupNumber; - - [XmlAttributeAttribute(DataType="date",AttributeName="CreationDate")] - DateTime Today; -}; - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - array^hexByte = {Convert::ToByte( 100 ),Convert::ToByte( 50 )}; - myGroup->GroupNumber = hexByte; - DateTime myDate = DateTime(2001,1,10); - myGroup->Today = myDate; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "Attributes.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp deleted file mode 100644 index bf8889f6772..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Group -{ -public: - - // Change the XML attribute name. - - [XmlAttributeAttribute(AttributeName="MgrName")] - String^ Name; - /* Use the AttributeName to collect all the XML attributes - in the XML-document instance. */ -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Serializing" ); - - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - /* Set the Name property, which will be generated - as an XML attribute. */ - myGroup->Name = "Wallace"; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Deserializing" ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myGroup->Name ); -} - -int main() -{ - /* To use the AttributeName to collect all the - XML attributes. Call SerializeObject to generate - an XML document and alter the document by adding - new XML attributes to it. Then comment out the SerializeObject - method, and call DeserializeObject. */ - SerializeObject( "MyAtts.xml" ); - DeserializeObject( "MyAtts.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp deleted file mode 100644 index dbc9a73c48f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Group -{ -public: - - [XmlAttributeAttribute(DataType="string")] - String^ Name; - - [XmlAttributeAttribute(DataType="base64Binary")] - array^Hex64Code; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 37de504e9b7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -// -public ref class Vehicle -{ -public: - - [XmlAttributeAttribute(Form=XmlSchemaForm::Qualified)] - String^ Maker; - - [XmlAttributeAttribute(Form=XmlSchemaForm::Unqualified)] - String^ ModelID; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 8cd4fd710f3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Car -{ -public: - - [XmlAttributeAttribute(Namespace="Make")] - String^ MakerName; - - [XmlAttributeAttribute(Namespace="Model")] - String^ ModelName; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp deleted file mode 100644 index 4dc40d33dd2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownAttribute( Object^ /*sender*/, XmlAttributeEventArgs^ e ) - { - System::Xml::XmlAttribute^ attr = e->Attr; - Console::WriteLine( "Unknown Attribute Name and Value: {0} = '{1}'", - attr->Name, attr->Value ); - Object^ x = e->ObjectBeingDeserialized; - Console::WriteLine( "ObjectBeingDeserialized: {0}", x ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp deleted file mode 100644 index 5d23724e8ea..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp +++ /dev/null @@ -1,113 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Instrument -{ -public: - String^ Name; -}; - -public ref class Brass: public Instrument -{ -public: - bool IsValved; -}; - -public ref class Orchestra -{ -public: - array^Instruments; -}; - -void SerializeObject( String^ filename ) -{ - /* Each overridden field, property, or type requires - an XmlAttributes object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Create an XmlElementAttribute to override the - field that returns Instrument objects. The overridden field - returns Brass objects instead. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the element to the collection of elements. - attrs->XmlElements->Add( attr ); - - // Create the XmlAttributeOverrides object. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - /* Add the type of the class that contains the overridden - member and the XmlAttributes to override it with to the - XmlAttributeOverrides object. */ - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object that will be serialized. - Orchestra^ band = gcnew Orchestra; - - // Create an object of the derived type. - Brass^ i = gcnew Brass; - i->Name = "Trumpet"; - i->IsValved = true; - array^myInstruments = {i}; - band->Instruments = myInstruments; - - // Serialize the object. - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Create an XmlElementAttribute to override the Instrument. - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the XmlElementAttribute to the collection of objects. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Orchestra^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - - /* The difference between deserializing the overridden - XML document and serializing it is this: To read the derived - object values, you must declare an object of the derived type - (Brass), and cast the Instrument instance to it. */ - Brass^ b; - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - b = dynamic_cast(i); - Console::WriteLine( "{0}\n{1}", b->Name, b->IsValved ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp deleted file mode 100644 index e474a5694c3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp +++ /dev/null @@ -1,102 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -ref class Band; -ref class Instrument; - -/* This is the class that will be overridden. The XmlIncludeAttribute -tells the XmlSerializer that the overriding type exists. */ - -[XmlInclude(Band::typeid)] -public ref class Orchestra -{ -public: - array^Instruments; -}; - -// This is the overriding class. -public ref class Band: public Orchestra -{ -public: - String^ BandName; -}; - -public ref class Instrument -{ -public: - String^ Name; -}; - -void SerializeObject( String^ filename ) -{ - /* Each object that is being overridden requires - an XmlAttributes object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - - // An XmlRootAttribute allows overriding the Orchestra class. - XmlRootAttribute^ xmlRoot = gcnew XmlRootAttribute; - - // Set the object to the XmlAttribute.XmlRoot property. - attrs->XmlRoot = xmlRoot; - - // Create an XmlAttributeOverrides object. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - // Add the XmlAttributes to the XmlAttributeOverrrides. - attrOverrides->Add( Orchestra::typeid, attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object using the derived class. - Band^ band = gcnew Band; - band->BandName = "NewBand"; - - // Create an Instrument. - Instrument^ i = gcnew Instrument; - i->Name = "Trumpet"; - array^myInstruments = {i}; - band->Instruments = myInstruments; - - // Serialize the object. - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlRootAttribute^ attr = gcnew XmlRootAttribute; - attrs->XmlRoot = attr; - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Deserialize the Band object. - Band^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - Console::WriteLine( i->Name ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp deleted file mode 100644 index ae9b594d0f2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -public ref class Sample -{ -public: - XmlSerializer^ CreateOverrider() - { - // Create an XmlAttributeOverrides object. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlAttributeAttribute to override the base class - object's XmlAttributeAttribute object. Give the overriding object - a new attribute name ("Code"). */ - XmlAttributeAttribute^ xAtt = gcnew XmlAttributeAttribute; - xAtt->AttributeName = "Code"; - - /* Create an instance of the XmlAttributes class and set the - XmlAttribute property to the XmlAttributeAttribute object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - attrs->XmlAttribute = xAtt; - - /* Add the XmlAttributes object to the XmlAttributeOverrides - and specify the type and member name to override. */ - xOver->Add( Group::typeid, "GroupCode", attrs ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp deleted file mode 100644 index d9d43cdf6b3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -public ref class Sample -{ -public: - XmlSerializer^ CreateOverrider() - { - // Create an XmlSerializer with overriding attributes. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - - // Set a new Namespace and ElementName for the root element. - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->ElementName = "NewGroup"; - attrs->XmlRoot = xRoot; - xOver->Add( Group::typeid, attrs ); - - // Get the XmlAttributes object, based on the type. - XmlAttributes^ tempAttrs; - tempAttrs = xOver[ Group::typeid ]; - - // Print the Namespace and ElementName of the root. - Console::WriteLine( tempAttrs->XmlRoot->Namespace ); - Console::WriteLine( tempAttrs->XmlRoot->ElementName ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp deleted file mode 100644 index 099c81b6664..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -public ref class Sample -{ -public: - XmlSerializer^ CreateOverrider() - { - // Create an XmlSerializer with overriding attributes. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlAttributeAttribute object and set the - AttributeName property. */ - XmlAttributeAttribute^ xAtt = gcnew XmlAttributeAttribute; - xAtt->AttributeName = "Code"; - - /* Create a new XmlAttributes object and set the - XmlAttributeAttribute object to the XmlAttribute property. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - attrs->XmlAttribute = xAtt; - - /* Add the XmlAttributes to the XmlAttributeOverrides object. The - name of the overridden attribute must be specified. */ - xOver->Add( Group::typeid, "GroupCode", attrs ); - - // Get the XmlAttributes object for the type and member. - XmlAttributes^ tempAttrs; - tempAttrs = xOver[Group::typeid, "GroupCode"]; - Console::WriteLine( tempAttrs->XmlAttribute->AttributeName ); - - // Create the XmlSerializer instance and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp deleted file mode 100644 index c0960e934fc..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp +++ /dev/null @@ -1,85 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Member -{ -public: - String^ MemberName; -}; - - -// This is the class that will be serialized. -public ref class Group -{ -public: - - // This field will be overridden. - array^Members; -}; - - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Creating XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an override for the XmlArray. - XmlArrayAttribute^ xArray = gcnew XmlArrayAttribute( "Staff" ); - xArray->Namespace = "http://www.cpandl.com"; - xAttrs->XmlArray = xArray; - xOver->Add( Group::typeid, "Members", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - Member^ m = gcnew Member; - m->MemberName = "Paul"; - array^temp = {m}; - myGroup->Members = temp; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - System::Collections::IEnumerator^ myEnum = myGroup->Members->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Member^ m = safe_cast(myEnum->Current); - Console::WriteLine( m->MemberName ); - } -} - -int main() -{ - SerializeObject( "OverrideArray.xml" ); - DeserializeObject( "OverrideArray.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp deleted file mode 100644 index d2aff93a0ce..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp +++ /dev/null @@ -1,107 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Member -{ -public: - String^ MemberName; -}; - -// This is the class that will be serialized. -public ref class Group -{ -public: - array^Members; -}; - -public ref class NewMember: public Member -{ -public: - int MemberID; -}; - -public ref class RetiredMember: public NewMember -{ -public: - DateTime RetireDate; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an override for the XmlArrayItem. - XmlArrayItemAttribute^ xArrayItem = gcnew XmlArrayItemAttribute( NewMember::typeid ); - xArrayItem->Namespace = "http://www.cpandl.com"; - xAttrs->XmlArrayItems->Add( xArrayItem ); - - // Add a second override. - XmlArrayItemAttribute^ xArrayItem2 = gcnew XmlArrayItemAttribute( RetiredMember::typeid ); - xArrayItem2->Namespace = "http://www.cpandl.com"; - xAttrs->XmlArrayItems->Add( xArrayItem2 ); - - // Add all overrides to XmlAttribueOverrides object. - xOver->Add( Group::typeid, "Members", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - NewMember^ m = gcnew NewMember; - m->MemberName = "Paul"; - m->MemberID = 2; - - // Create a second member. - RetiredMember^ m2 = gcnew RetiredMember; - m2->MemberName = "Renaldo"; - m2->MemberID = 23; - m2->RetireDate = DateTime(2000,10,10); - array^temp = {m,m2}; - myGroup->Members = temp; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - System::Collections::IEnumerator^ myEnum = myGroup->Members->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Member^ m = safe_cast(myEnum->Current); - Console::WriteLine( m->MemberName ); - } -} - -int main() -{ - SerializeObject( "OverrideArrayItem.xml" ); - DeserializeObject( "OverrideArrayItem.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp deleted file mode 100644 index 080d02f704e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,78 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - - // This is the attribute that will be overridden. - - [XmlAttributeAttribute] - String^ GroupName; - int GroupNumber; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - /* Create an overriding XmlAttributeAttribute set it to - the XmlAttribute property of the XmlAttributes object.*/ - XmlAttributeAttribute^ xAttribute = gcnew XmlAttributeAttribute( "SplinterName" ); - xAttrs->XmlAttribute = xAttribute; - - // Add to the XmlAttributeOverrides. Specify the member name. - xOver->Add( Group::typeid, "GroupName", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - /* Set the Name property, which will be generated - as an XML attribute. */ - myGroup->GroupName = ".NET"; - myGroup->GroupNumber = 1; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( myGroup->GroupNumber ); -} - -int main() -{ - SerializeObject( "OverrideAttribute.xml" ); - DeserializeObject( "OverrideAttribute.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp deleted file mode 100644 index 79e6e301177..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,112 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Instrument -{ -public: - String^ Name; -}; - -public ref class Brass: public Instrument -{ -public: - bool IsValved; -}; - -public ref class Orchestra -{ -public: - array^Instruments; -}; - -void SerializeObject( String^ filename ) -{ - /* Each overridden field, property, or type requires - an XmlAttributes object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Create an XmlElementAttribute to override the - field that returns Instrument objects. The overridden field - returns Brass objects instead. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the element to the collection of elements. - attrs->XmlElements->Add( attr ); - - // Create the XmlAttributeOverrides object. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - /* Add the type of the class that contains the overridden - member and the XmlAttributes to override it with to the - XmlAttributeOverrides object. */ - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object that will be serialized. - Orchestra^ band = gcnew Orchestra; - - // Create an object of the derived type. - Brass^ i = gcnew Brass; - i->Name = "Trumpet"; - i->IsValved = true; - array^myInstruments = {i}; - band->Instruments = myInstruments; - - // Serialize the object. - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Create an XmlElementAttribute to override the Instrument. - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the element to the collection of elements. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Orchestra^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - - /* The difference between deserializing the overridden - XML document and serializing it is this: To read the derived - object values, you must declare an object of the derived type - (Brass), and cast the Instrument instance to it. */ - Brass^ b; - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - b = dynamic_cast(i); - Console::WriteLine( "{0}\n{1}", b->Name, b->IsValved ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp deleted file mode 100644 index 40f6a96deb7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp +++ /dev/null @@ -1,88 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::ComponentModel; - -// This is the class that will be serialized. -public ref class Pet -{ -public: - - // The default value for the Animal field is "Dog". - - [DefaultValueAttribute("Dog")] - String^ Animal; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an override for the default value of the GroupName. - Object^ defaultAnimal = "Cat"; - xAttrs->XmlDefaultValue = defaultAnimal; - - // Add all the XmlAttributes to the XmlAttributeOverrides object. - xOver->Add( Pet::typeid, "Animal", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Pet::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Pet^ myPet = gcnew Pet; - - /* Set the Animal property. If you set it to the default value, - which is "Cat" (the value assigned to the XmlDefaultValue - of the XmlAttributes object), no value will be serialized. - If you change the value to any other value (including "Dog"), - the value will be serialized. - */ - // The default value "Cat" will be assigned (nothing serialized). - myPet->Animal = ""; - - // Uncommenting the next line also results in the default - // value because Cat is the default value (not serialized). - // myPet.Animal = "Cat"; - // Uncomment the next line to see the value serialized: - // myPet.Animal = "fish"; - // This will also be serialized because Dog is not the - // default anymore. - // myPet.Animal = "Dog"; - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myPet ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Pet^ myPet = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myPet->Animal ); -} - -int main() -{ - SerializeObject( "OverrideDefaultValue.xml" ); - DeserializeObject( "OverrideDefaultValue.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp deleted file mode 100644 index dc3a90e6177..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp +++ /dev/null @@ -1,101 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; - -public ref class Car -{ -public: - String^ Name; -}; - -public ref class Plane -{ -public: - String^ Name; -}; - -public ref class Truck -{ -public: - String^ Name; -}; - -public ref class Train -{ -public: - String^ Name; -}; - -public ref class Transportation -{ -public: - - // Subsequent code overrides these two XmlElementAttributes. - - [XmlElement(Car::typeid), - XmlElement(Plane::typeid)] - ArrayList^ Vehicles; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributes and XmlAttributeOverrides objects. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlElementAttribute to override - the Vehicles property. */ - XmlElementAttribute^ xElement1 = gcnew XmlElementAttribute( Truck::typeid ); - - // Add the XmlElementAttribute to the collection. - attrs->XmlElements->Add( xElement1 ); - - /* Create a second XmlElementAttribute, and - add it to the collection. */ - XmlElementAttribute^ xElement2 = gcnew XmlElementAttribute( Train::typeid ); - attrs->XmlElements->Add( xElement2 ); - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Transportation::typeid, "Vehicles", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Transportation::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object and serialize it. - Transportation^ myTransportation = gcnew Transportation; - - /* Create two new override objects that can be - inserted into the array. */ - myTransportation->Vehicles = gcnew ArrayList; - Truck^ myTruck = gcnew Truck; - myTruck->Name = "MyTruck"; - Train^ myTrain = gcnew Train; - myTrain->Name = "MyTrain"; - myTransportation->Vehicles->Add( myTruck ); - myTransportation->Vehicles->Add( myTrain ); - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myTransportation ); -} - -int main() -{ - SerializeObject( "OverrideElement.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp deleted file mode 100644 index 9b65599120b..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public enum class FoodType -{ - // Subsequent code overrides these enumerations. - Low, High -}; - -// This is the class that will be serialized. -public ref class Food -{ -public: - FoodType Type; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an XmlEnumAttribute for the FoodType.Low enumeration. - XmlEnumAttribute^ xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Cold"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "Low", xAttrs ); - - // Add an XmlEnumAttribute for the FoodType.High enumeration. - xAttrs = gcnew XmlAttributes; - xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Hot"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "High", xAttrs ); - - // Create the XmlSerializer, and return it. - return gcnew XmlSerializer( Food::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Food^ myFood = gcnew Food; - - // Set the object properties. - myFood->Type = FoodType::High; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myFood ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Food^ myFood = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myFood->Type ); -} - -int main() -{ - SerializeObject( "OverrideEnum.xml" ); - DeserializeObject( "OverrideEnum.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp deleted file mode 100644 index 1f586f80547..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - - // The GroupName value will be serialized--unless it's overridden. - String^ GroupName; - - /* This field will be ignored when serialized-- - unless it's overridden. */ - - [XmlIgnoreAttribute] - String^ Comment; -}; - - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Setting XmlIgnore to false overrides the XmlIgnoreAttribute - applied to the Comment field. Thus it will be serialized.*/ - attrs->XmlIgnore = false; - xOver->Add( Group::typeid, "Comment", attrs ); - - /* Use the XmlIgnore to instruct the XmlSerializer to ignore - the GroupName instead. */ - attrs = gcnew XmlAttributes; - attrs->XmlIgnore = true; - xOver->Add( Group::typeid, "GroupName", attrs ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object to serialize and set its properties. - Group^ myGroup = gcnew Group; - myGroup->GroupName = ".NET"; - myGroup->Comment = "My Comment..."; - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Serialize the object and close the TextWriter. - xSer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "IgnoreXml.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp deleted file mode 100644 index 42c1f3a3503..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -// Return an XmlSerializer for overriding attributes. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributes and XmlAttributeOverrides objects. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - - // Set a new Namespace and ElementName for the root element. - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->ElementName = "NewGroup"; - attrs->XmlRoot = xRoot; - - /* Add the XmlAttributes object to the XmlAttributeOverrides. - No member name is needed because the whole class is - overridden. */ - xOver->Add( Group::typeid, attrs ); - - // Get the XmlAttributes object, based on the type. - XmlAttributes^ tempAttrs; - tempAttrs = xOver[ Group::typeid ]; - - // Print the Namespace and ElementName of the root. - Console::WriteLine( tempAttrs->XmlRoot->Namespace ); - Console::WriteLine( tempAttrs->XmlRoot->ElementName ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create the XmlSerializer using the CreateOverrider method. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object to serialize. - Group^ myGroup = gcnew Group; - myGroup->GroupName = ".NET"; - myGroup->GroupCode = 123; - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Serialize the object and close the TextWriter. - xSer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "OverrideRoot.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp deleted file mode 100644 index e2732ed2c57..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp +++ /dev/null @@ -1,74 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - // This field will be serialized as XML text. - String^ Comment; -}; - -// Return an XmlSerializer to be used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - /* Create an XmlTextAttribute and assign it to the XmlText - property. This instructs the XmlSerializer to treat the - Comment field as XML text. */ - XmlTextAttribute^ xText = gcnew XmlTextAttribute; - xAttrs->XmlText = xText; - xOver->Add( Group::typeid, "Comment", xAttrs ); - - // Create the XmlSerializer, and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - myGroup->Comment = "Great Stuff!"; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( myGroup->Comment ); -} - -int main() -{ - SerializeObject( "OverrideText.xml" ); - DeserializeObject( "OverrideText.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp deleted file mode 100644 index d2cccc13596..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp +++ /dev/null @@ -1,69 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Car -{ -public: - int ID; -}; - -public ref class Transportation -{ -public: - array^Cars; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributes and XmlAttributeOverrides objects. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlTypeAttribute and change the name of the - XML type. */ - XmlTypeAttribute^ xType = gcnew XmlTypeAttribute; - xType->TypeName = "Autos"; - - // Set the XmlTypeAttribute to the XmlType property. - attrs->XmlType = xType; - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Car::typeid, attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Transportation::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create object and serialize it. - Transportation^ myTransportation = gcnew Transportation; - Car^ c1 = gcnew Car; - c1->ID = 12; - Car^ c2 = gcnew Car; - c2->ID = 44; - array^temp0 = {c1,c2}; - myTransportation->Cars = temp0; - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myTransportation ); -} - -int main() -{ - SerializeObject( "XmlType.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp deleted file mode 100644 index eea4fa29c6d..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,115 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - /* Set the element name and namespace of the XML element. - By applying an XmlElementAttribute to an array, you instruct - the XmlSerializer to serialize the array as a series of XML - elements, instead of a nested set of elements. */ - - [XmlElement( - ElementName="Members", - Namespace="http://www.cpandl.com")] - array^Employees; - - [XmlElement(DataType="snippet1>", - ElementName="Building")] - double GroupID; - - [XmlElement(DataType="hexBinary")] - array^HexBytes; - - [XmlElement(DataType="boolean")] - bool IsActive; - - [XmlElement(Type=::Manager::typeid)] - Employee^ Manager; - - [XmlElement(Int32::typeid, - ElementName="ObjectNumber"), - XmlElement(String::typeid, - ElementName="ObjectString")] - ArrayList^ ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // Create the XmlSerializer. - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - - /* Create an instance of the group to serialize, and set - its properties. */ - Group^ group = gcnew Group; - group->GroupID = 10.089f; - group->IsActive = false; - array^temp0 = {Convert::ToByte( 100 )}; - group->HexBytes = temp0; - Employee^ x = gcnew Employee; - Employee^ y = gcnew Employee; - x->Name = "Jack"; - y->Name = "Jill"; - array^temp1 = {x,y}; - group->Employees = temp1; - Manager^ mgr = gcnew Manager; - mgr->Name = "Sara"; - mgr->Level = 4; - group->Manager = mgr; - - /* Add a number and a string to the - ArrayList returned by the ExtraInfo property. */ - group->ExtraInfo = gcnew ArrayList; - group->ExtraInfo->Add( 42 ); - group->ExtraInfo->Add( "Answer" ); - - // Serialize the object, and close the TextWriter. - s->Serialize( writer, group ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlSerializer^ x = gcnew XmlSerializer( Group::typeid ); - Group^ g = dynamic_cast(x->Deserialize( fs )); - Console::WriteLine( g->Manager->Name ); - Console::WriteLine( g->GroupID ); - Console::WriteLine( g->HexBytes[ 0 ] ); - IEnumerator^ myEnum = g->Employees->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Employee^ e = safe_cast(myEnum->Current); - Console::WriteLine( e->Name ); - } -} - -int main() -{ - SerializeObject( "FirstDoc.xml" ); - DeserializeObject( "FirstDoc.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp deleted file mode 100644 index dac3339b9d7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Group -{ -public: - - /* Apply two XmlElementAttributes to the field. Set the DataType - to string an int to allow the ArrayList to accept - both types. The Namespace is also set to different values - for each type. */ - - [XmlElement(DataType="string", - Type=String::typeid, - Namespace="http://www.cpandl.com"), - XmlElement(DataType="snippet1>", - Namespace="http://www.cohowinery.com", - Type=Int32::typeid)] - ArrayList^ ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // A TextWriter is needed to write the file. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // Create the object to serialize. - Group^ myGroup = gcnew Group; - - /* Add a string and an integer to the ArrayList returned - by the ExtraInfo field. */ - myGroup->ExtraInfo = gcnew ArrayList; - myGroup->ExtraInfo->Add( "hello" ); - myGroup->ExtraInfo->Add( 100 ); - - // Serialize the object and close the TextWriter. - s->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "ElementTypes.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp deleted file mode 100644 index c73eab60f3b..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using - -using namespace System; -using namespace System::Xml; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class XClass -{ -public: - /* The XML element name will be XName - instead of the default ClassName. */ - [XmlElement(ElementName="XName")] - String^ ClassName; -}; -// - -int main(){} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 323a5e3febf..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlElement(Form=XmlSchemaForm::Unqualified)] - String^ ClassName; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index 496244672df..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlElement(IsNullable=false)] - String^ Group; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp deleted file mode 100644 index 217959b7fad..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp +++ /dev/null @@ -1,64 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - [XmlElement(Manager::typeid)] - array^Staff; - - [XmlElement(Int32::typeid), - XmlElement(String::typeid), - XmlElement(DateTime::typeid)] - ArrayList^ ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid ); - - // Create object and serialize it. - Group^ myGroup = gcnew Group; - Manager^ e1 = gcnew Manager; - e1->Name = "Manager1"; - Manager^ m1 = gcnew Manager; - m1->Name = "Manager2"; - m1->Level = 4; - array^emps = {e1,m1}; - myGroup->Staff = emps; - myGroup->ExtraInfo = gcnew ArrayList; - myGroup->ExtraInfo->Add( ".NET" ); - myGroup->ExtraInfo->Add( 42 ); - myGroup->ExtraInfo->Add( DateTime(2001,1,1) ); - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "TypeEx.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp deleted file mode 100644 index f06647e1954..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlElement] - String^ TeacherName; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp deleted file mode 100644 index a92464e29dc..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Transportation -{ -public: - - [XmlElement("Cars")] - String^ Vehicles; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp deleted file mode 100644 index 701b642c490..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp +++ /dev/null @@ -1,96 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Instrument -{ -public: - String^ Name; -}; - -public ref class Brass: public Instrument -{ -public: - bool IsValved; -}; - -public ref class Orchestra -{ -public: - array^Instruments; -}; - -void SerializeObject( String^ filename ) -{ - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Creates an XmlElementAttribute that overrides the Instrument type. - XmlElementAttribute^ attr = gcnew XmlElementAttribute( Brass::typeid ); - attr->ElementName = "Brass"; - - // Adds the element to the collection of elements. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Creates the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Creates the object to serialize. - Orchestra^ band = gcnew Orchestra; - - // Creates an object of the derived type. - Brass^ i = gcnew Brass; - i->Name = "Trumpet"; - i->IsValved = true; - array^myInstruments = {i}; - band->Instruments = myInstruments; - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Creates an XmlElementAttribute that override the Instrument type. - XmlElementAttribute^ attr = gcnew XmlElementAttribute( Brass::typeid ); - attr->ElementName = "Brass"; - - // Adds the element to the collection of elements. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Creates the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Orchestra^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - - /* Deserializing differs from serializing. To read the - derived-object values, declare an object of the derived - type (Brass) and cast the Instrument instance to it. */ - Brass^ b; - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - b = dynamic_cast(i); - Console::WriteLine( "{0}\n{1}", b->Name, b->IsValved ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp deleted file mode 100644 index 000e548b46f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,100 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; - -public ref class Car -{ -public: - String^ Name; -}; - -public ref class Plane -{ -public: - String^ Name; -}; - -public ref class Truck -{ -public: - String^ Name; -}; - -public ref class Train -{ -public: - String^ Name; -}; - -public ref class Transportation -{ -public: - - // Override these two XmlElementAttributes. - - [XmlElement(Car::typeid), - XmlElement(Plane::typeid)] - ArrayList^ Vehicles; -}; - -XmlSerializer^ CreateOverrider() -{ - // Create XmlAtrributes and XmlAttributeOverrides instances. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlElementAttributes object to override - one of the attributes applied to the Vehicles property. */ - XmlElementAttribute^ xElement1 = gcnew XmlElementAttribute( Truck::typeid ); - - // Add the XmlElementAttribute to the collection. - attrs->XmlElements->Add( xElement1 ); - - /* Create a second XmlElementAttribute and - add it to the collection. */ - XmlElementAttribute^ xElement2 = gcnew XmlElementAttribute( Train::typeid ); - attrs->XmlElements->Add( xElement2 ); - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Transportation::typeid, "Vehicles", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Transportation::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object. - Transportation^ myTransportation = gcnew Transportation; - - /* Create two new, overriding objects that can be - inserted into the Vehicles array. */ - myTransportation->Vehicles = gcnew ArrayList; - Truck^ myTruck = gcnew Truck; - myTruck->Name = "MyTruck"; - Train^ myTrain = gcnew Train; - myTrain->Name = "MyTrain"; - myTransportation->Vehicles->Add( myTruck ); - myTransportation->Vehicles->Add( myTrain ); - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myTransportation ); -} - -int main() -{ - SerializeObject( "OverrideElement.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp deleted file mode 100644 index 3933ca7d495..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Truck{ - // Class added so sample will compile -}; - -public ref class Train{ - // Class added so sample will compile -}; - -public ref class Transportation{ - // Class added so sample will compile -}; - -public ref class Sample -{ - // -public: - XmlSerializer^ CreateOverrider() - { - // Create XmlAttributes and XmlAttributeOverrides instances. - - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = - gcnew XmlAttributeOverrides; - - /* Create an XmlElementAttributes to override - the Vehicles property. */ - XmlElementAttribute^ xElement1 = - gcnew XmlElementAttribute( Truck::typeid ); - // Add the XmlElementAttribute to the collection. - attrs->XmlElements->Add( xElement1 ); - - /* Create a second XmlElementAttribute, and - add to the collection. */ - XmlElementAttribute^ xElement2 = - gcnew XmlElementAttribute( Train::typeid ); - attrs->XmlElements->Add( xElement2 ); - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Transportation::typeid, "Vehicles", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( - Transportation::typeid,xOver ); - return xSer; - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp deleted file mode 100644 index b82f373dbe0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public enum class EmployeeStatus -{ - [XmlEnum(Name = "Single")] - One, - [XmlEnum(Name = "Double")] - Two, - [XmlEnum(Name = "Triple")] - Three -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp deleted file mode 100644 index d494e993e3e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public enum class EmployeeStatus -{ - [XmlEnum("Single")] - One, - [XmlEnum("Double")] - Two, - [XmlEnum("Triple")] - Three -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp deleted file mode 100644 index d7f0debeaec..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public enum class FoodType -{ - // Subsequent code overrides these enumerations. - Low, High -}; - -// This is the class that will be serialized. -public ref class Food -{ -public: - FoodType Type; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an XmlEnumAttribute for the FoodType.Low enumeration. - XmlEnumAttribute^ xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Cold"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "Low", xAttrs ); - - // Add an XmlEnumAttribute for the FoodType.High enumeration. - xAttrs = gcnew XmlAttributes; - xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Hot"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "High", xAttrs ); - - // Create the XmlSerializer, and return it. - return gcnew XmlSerializer( Food::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Food^ myFood = gcnew Food; - - // Set the object properties. - myFood->Type = FoodType::High; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myFood ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Food^ myFood = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myFood->Type ); -} - -int main() -{ - SerializeObject( "OverrideEnum.xml" ); - DeserializeObject( "OverrideEnum.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp deleted file mode 100644 index 7298f812c7a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Group -{ -public: - - // The XmlSerializer ignores this field. - - [XmlIgnore] - String^ Comment; - - // The XmlSerializer serializes this field. - String^ GroupName; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp deleted file mode 100644 index cbfdda004f2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -ref class Employee; - -ref class Manager; - -ref class Group -{ -public: - array^Employees; -}; - -// Instruct the XmlSerializer to accept Manager types as well. -[XmlInclude(Manager::typeid)] -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - Group^ group = gcnew Group; - Manager^ manager = gcnew Manager; - Employee^ emp1 = gcnew Employee; - Employee^ emp2 = gcnew Employee; - manager->Name = "Zeus"; - manager->Level = 2; - emp1->Name = "Ares"; - emp2->Name = "Artemis"; - array^emps = {manager,emp1,emp2}; - group->Employees = emps; - s->Serialize( writer, group ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlSerializer^ x = gcnew XmlSerializer( Group::typeid ); - Group^ g = dynamic_cast(x->Deserialize( fs )); - Console::Write( "Members:" ); - System::Collections::IEnumerator^ myEnum = g->Employees->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Employee^ e = safe_cast(myEnum->Current); - Console::WriteLine( "\t{0}", e->Name ); - } -} - -int main() -{ - SerializeObject( "IncludeExample.xml" ); - DeserializeObject( "IncludeExample.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp deleted file mode 100644 index 8ba6ec67f15..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Vehicle{}; - -public ref class Car: public Vehicle{}; - -public ref class Truck: public Vehicle{}; - -public ref class Sample -{ -public: - - [WebMethodAttribute] - [XmlInclude(Car::typeid)] - [XmlInclude(Truck::typeid)] - Vehicle^ ReturnVehicle( int i ) - { - if ( i == 0 ) - return gcnew Car; - else - return gcnew Truck; - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp deleted file mode 100644 index 78b7ac99698..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode LocalName: {0}", e->LocalName ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp deleted file mode 100644 index de9d0304ae4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ -private: - // - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Name: {0}", e->Name ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp deleted file mode 100644 index 68985474069..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Namespace URI: {0}", e->NamespaceURI ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp deleted file mode 100644 index bd6a1e29d72..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - XmlNodeType myNodeType = e->NodeType; - Console::WriteLine( myNodeType ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp deleted file mode 100644 index 88a67fdab41..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Object^ o = e->ObjectBeingDeserialized; - Console::WriteLine( "Object being deserialized: {0}", o ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp deleted file mode 100644 index a4734b7e012..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Text: {0}", e->Text ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp deleted file mode 100644 index b4318feda2a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Class1 -{ - // -private: - void DeserializeItem( String^ filename ) - { - XmlSerializer^ mySerializer = gcnew XmlSerializer( ObjectToDeserialize::typeid ); - - // Add an instance of the delegate to the event. - mySerializer->UnknownNode += gcnew XmlNodeEventHandler( this, &Class1::Serializer_UnknownNode ); - - // A FileStream is needed to read the file to deserialize. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - ObjectToDeserialize^ o = dynamic_cast(mySerializer->Deserialize( fs )); - } - - void Serializer_UnknownNode( Object^ sender, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Name: {0}", e->Name ); - Console::WriteLine( "UnknownNode LocalName: {0}", e->LocalName ); - Console::WriteLine( "UnknownNode Namespace URI: {0}", e->NamespaceURI ); - Console::WriteLine( "UnknownNode Text: {0}", e->Text ); - Object^ o = e->ObjectBeingDeserialized; - Console::WriteLine( "Object being deserialized {0}", o ); - XmlNodeType myNodeType = e->NodeType; - Console::WriteLine( myNodeType ); - } - // - -public: - - ref class ObjectToDeserialize{}; -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp deleted file mode 100644 index 705ea6b1244..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -[XmlRoot(Namespace="www.contoso.com", -ElementName="MyGroupName", -DataType="string", -IsNullable=true)] -public ref class Group -{ -private: - String^ groupNameValue; - -public: - - // Insert code for the Group class. - Group(){} - - Group( String^ groupNameVal ) - { - groupNameValue = groupNameVal; - } - - property String^ GroupName - { - String^ get() - { - return groupNameValue; - } - void set( String^ value ) - { - groupNameValue = value; - } - - } - -}; - -void SerializeGroup() -{ - // Create an instance of the Group class, and an - // instance of the XmlSerializer to serialize it. - Group^ myGroup = gcnew Group( "Redmond" ); - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // A FileStream is used to write the file. - FileStream^ fs = gcnew FileStream( "group.xml",FileMode::Create ); - ser->Serialize( fs, myGroup ); - fs->Close(); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( "Done" ); - Console::ReadLine(); -} - -int main() -{ - SerializeGroup(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index 9780f3bb003..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; - -// Apply the XmlRootAttribute and set the IsNullable property to false. - -[XmlRoot(IsNullable=false)] -public ref class Group -{ -public: - String^ Name; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object to serialize. - Group^ mygroup = nullptr; - - // Serialize the object, and close the TextWriter. - s->Serialize( writer, mygroup ); - writer->Close(); -} - -int main() -{ - Console::WriteLine( "Running" ); - SerializeObject( "NullDoc.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 4d0cd2a4a61..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlRoot(Namespace="http://www.cpandl.com")] -public ref class Group{}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp deleted file mode 100644 index ee176b3d4b4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that is the default root element. -public ref class MyClass -{ -public: - String^ Name; -}; - -XmlSerializer^ CreateOverrider(); -void SerializeOrder( String^ filename ) -{ - // Create an XmlSerializer instance using the method below. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object, and set its Name property. - MyClass^ myClass = gcnew MyClass; - myClass->Name = "New Class Name"; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myClass ); - writer->Close(); -} - -// Return an XmlSerializer to override the root serialization. -XmlSerializer^ CreateOverrider() -{ - // Create an XmlAttributes to override the default root element. - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Create an XmlRootAttribute and set its element name and namespace. - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - xRoot->ElementName = "OverriddenRootElementName"; - xRoot->Namespace = "http://www.microsoft.com"; - - // Set the XmlRoot property to the XmlRoot object. - attrs->XmlRoot = xRoot; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Add the XmlAttributes object to the - XmlAttributeOverrides object. */ - xOver->Add( MyClass::typeid, attrs ); - - // Create the Serializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( MyClass::typeid,xOver ); - return xSer; -} - -int main() -{ - SerializeOrder( "OverrideAttribute.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer Example/CPP/source.cpp deleted file mode 100644 index 0bfeccd401c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer Example/CPP/source.cpp +++ /dev/null @@ -1,216 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; -ref class Address; -ref class OrderedItem; - -/* The XmlRootAttribute allows you to set an alternate name - (PurchaseOrder) of the XML element, the element namespace; by - default, the XmlSerializer uses the class name. The attribute - also allows you to set the XML namespace for the element. Lastly, - the attribute sets the IsNullable property, which specifies whether - the xsi:null attribute appears if the class instance is set to - a null reference. */ - -[XmlRootAttribute("PurchaseOrder",Namespace="http://www.cpandl.com", -IsNullable=false)] -public ref class PurchaseOrder -{ -public: - Address^ ShipTo; - String^ OrderDate; - - /* The XmlArrayAttribute changes the XML element name - from the default of "OrderedItems" to "Items". */ - - [XmlArrayAttribute("Items")] - array^OrderedItems; - Decimal SubTotal; - Decimal ShipCost; - Decimal TotalCost; -}; - -public ref class Address -{ -public: - - /* The XmlAttribute instructs the XmlSerializer to serialize the Name - field as an XML attribute instead of an XML element (the default - behavior). */ - - [XmlAttributeAttribute] - String^ Name; - String^ Line1; - - /* Setting the IsNullable property to false instructs the - XmlSerializer that the XML attribute will not appear if - the City field is set to a null reference. */ - - [XmlElementAttribute(IsNullable=false)] - String^ City; - String^ State; - String^ Zip; -}; - -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - /* Calculate is a custom method that calculates the price per item, - and stores the value in a field. */ - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } - -}; - -public ref class Test -{ -public: - static void main() - { - // Read and write purchase orders. - Test^ t = gcnew Test; - t->CreatePO( "po.xml" ); - t->ReadPO( "po.xml" ); - } - -private: - void CreatePO( String^ filename ) - { - // Create an instance of the XmlSerializer class; - // specify the type of object to serialize. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - PurchaseOrder^ po = gcnew PurchaseOrder; - - // Create an address to ship and bill to. - Address^ billAddress = gcnew Address; - billAddress->Name = "Teresa Atkinson"; - billAddress->Line1 = "1 Main St."; - billAddress->City = "AnyTown"; - billAddress->State = "WA"; - billAddress->Zip = "00000"; - - // Set ShipTo and BillTo to the same addressee. - po->ShipTo = billAddress; - po->OrderDate = System::DateTime::Now.ToLongDateString(); - - // Create an OrderedItem object. - OrderedItem^ i1 = gcnew OrderedItem; - i1->ItemName = "Widget S"; - i1->Description = "Small widget"; - i1->UnitPrice = (Decimal)5.23; - i1->Quantity = 3; - i1->Calculate(); - - // Insert the item into the array. - array^items = {i1}; - po->OrderedItems = items; - - // Calculate the total cost. - Decimal subTotal = Decimal(0); - System::Collections::IEnumerator^ myEnum = items->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - OrderedItem^ oi = safe_cast(myEnum->Current); - subTotal = subTotal + oi->LineTotal; - } - - po->SubTotal = subTotal; - po->ShipCost = (Decimal)12.51; - po->TotalCost = po->SubTotal + po->ShipCost; - - // Serialize the purchase order, and close the TextWriter. - serializer->Serialize( writer, po ); - writer->Close(); - } - -protected: - void ReadPO( String^ filename ) - { - // Create an instance of the XmlSerializer class; - // specify the type of object to be deserialized. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - - /* If the XML document has been altered with unknown - nodes or attributes, handle them with the - UnknownNode and UnknownAttribute events.*/ - serializer->UnknownNode += gcnew XmlNodeEventHandler( this, &Test::serializer_UnknownNode ); - serializer->UnknownAttribute += gcnew XmlAttributeEventHandler( this, &Test::serializer_UnknownAttribute ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - PurchaseOrder^ po; - - /* Use the Deserialize method to restore the object's state with - data from the XML document. */ - po = dynamic_cast(serializer->Deserialize( fs )); - - // Read the order date. - Console::WriteLine( "OrderDate: {0}", po->OrderDate ); - - // Read the shipping address. - Address^ shipTo = po->ShipTo; - ReadAddress( shipTo, "Ship To:" ); - - // Read the list of ordered items. - array^items = po->OrderedItems; - Console::WriteLine( "Items to be shipped:" ); - System::Collections::IEnumerator^ myEnum1 = items->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - OrderedItem^ oi = safe_cast(myEnum1->Current); - Console::WriteLine( "\t{0}\t{1}\t{2}\t{3}\t{4}", oi->ItemName, oi->Description, oi->UnitPrice, oi->Quantity, oi->LineTotal ); - } - - Console::WriteLine( "\t\t\t\t\t Subtotal\t{0}", po->SubTotal ); - Console::WriteLine( "\t\t\t\t\t Shipping\t{0}", po->ShipCost ); - Console::WriteLine( "\t\t\t\t\t Total\t\t{0}", po->TotalCost ); - } - - void ReadAddress( Address^ a, String^ label ) - { - // Read the fields of the Address object. - Console::WriteLine( label ); - Console::WriteLine( "\t{0}", a->Name ); - Console::WriteLine( "\t{0}", a->Line1 ); - Console::WriteLine( "\t{0}", a->City ); - Console::WriteLine( "\t{0}", a->State ); - Console::WriteLine( "\t{0}", a->Zip ); - Console::WriteLine(); - } - -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "Unknown Node:{0}\t{1}", e->Name, e->Text ); - } - - void serializer_UnknownAttribute( Object^ /*sender*/, XmlAttributeEventArgs^ e ) - { - System::Xml::XmlAttribute^ attr = e->Attr; - Console::WriteLine( "Unknown attribute {0}='{1}'", attr->Name, attr->Value ); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp deleted file mode 100644 index b488c27b932..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void TestDocument( String^ filename, Type^ objType ) - { - // Using a FileStream, create an XmlTextReader. - Stream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlReader^ reader = gcnew XmlTextReader( fs ); - XmlSerializer^ serializer = gcnew XmlSerializer( objType ); - if ( serializer->CanDeserialize( reader ) ) - { - Object^ o = serializer->Deserialize( reader ); - } - fs->Close(); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp deleted file mode 100644 index 542444fb61a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be deserialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void DeserializeObject(String^ filename) -{ - Console::WriteLine("Reading with Stream"); - - // Create an instance of the XmlSerializer. - XmlSerializer^ serializer = gcnew XmlSerializer(OrderedItem::typeid); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Reading the XML document requires a FileStream. - Stream^ reader = gcnew FileStream(filename, FileMode::Open); - - try - { - // Call the Deserialize method to restore the object's state. - i = dynamic_cast(serializer->Deserialize(reader)); - } - finally - { - delete reader; - } - - // Write out the properties of the object. - Console::Write("{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal); -} - -int main() -{ - // Read a purchase order. - DeserializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp deleted file mode 100644 index b803c3b61af..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml::Serialization; - -// This is the class that will be deserialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Reading with TextReader" ); - - // Create an instance of the XmlSerializer specifying type. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - - /* Create a TextReader to read the file. Specify an - Encoding to use. */ - TextReader^ reader = gcnew StreamReader( filename,Encoding::Unicode ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Use the Deserialize method to restore the object's state. - i = dynamic_cast(serializer->Deserialize( reader )); - - // Write out the properties of the object. - Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal ); -} - -int main() -{ - // Read a purchase order. - DeserializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp deleted file mode 100644 index 3b2738346ee..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be deserialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Reading with XmlReader" ); - - // Create an instance of the XmlSerializer specifying type and namespace. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlReader^ reader = gcnew XmlTextReader( fs ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Use the Deserialize method to restore the object's state. - i = dynamic_cast(serializer->Deserialize( reader )); - - // Write out the properties of the object. - Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal ); -} - -int main() -{ - // Read a purchase order. - DeserializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp deleted file mode 100644 index a9b0d0bf54e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -/* Three classes are included here. Each one will -be used to create three XmlSerializer objects. */ -public ref class Instrument -{ -public: - String^ InstrumentName; -}; - -public ref class Player -{ -public: - String^ PlayerName; -}; - -public ref class Piece -{ -public: - String^ PieceName; -}; - -void GetSerializers() -{ - // Create an array of types. - array^types = gcnew array(3); - types[ 0 ] = Instrument::typeid; - types[ 1 ] = Player::typeid; - types[ 2 ] = Piece::typeid; - - // Create an array for XmlSerializer objects. - array^serializers = gcnew array(3); - serializers = XmlSerializer::FromTypes( types ); - - // Create one Instrument and serialize it. - Instrument^ i = gcnew Instrument; - i->InstrumentName = "Piano"; - - // Create a TextWriter to write with. - TextWriter^ writer = gcnew StreamWriter( "Inst.xml" ); - serializers[ 0 ]->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - GetSerializers(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp deleted file mode 100644 index deb65e2782e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With TextWriter" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - /* Create a StreamWriter to write with. First create a FileStream - object, and create the StreamWriter specifying an Encoding to use. */ - FileStream^ fs = gcnew FileStream( filename,FileMode::Create ); - TextWriter^ writer = gcnew StreamWriter( fs,gcnew UTF8Encoding ); - - // Serialize using the XmlTextWriter. - serializer->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp deleted file mode 100644 index c635e566468..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With TextWriter" ); - - // Create an XmlSerializer instance using the type. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlSerializerNamespaces object. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Add two namespaces with prefixes. - ns->Add( "inventory", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create a StreamWriter to write with. - TextWriter^ writer = gcnew StreamWriter( filename ); - - /* Serialize using the object using the TextWriter - and namespaces. */ - serializer->Serialize( writer, i, ns ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp deleted file mode 100644 index 053d871e78a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With Stream" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create a FileStream to write with. - Stream^ writer = gcnew FileStream( filename,FileMode::Create ); - - // Serialize the object, and close the TextWriter - serializer->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp deleted file mode 100644 index baf2cd1b7c8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp +++ /dev/null @@ -1,91 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With Stream" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlSerializerNamespaces object. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Add two prefix-namespace pairs. - ns->Add( "inventory", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create a FileStream to write with. - Stream^ writer = gcnew FileStream( filename,FileMode::Create ); - - // Serialize the object, and close the TextWriter - serializer->Serialize( writer, i, ns ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Reading with Stream" ); - - // Create an instance of the XmlSerializer. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - - // Writing the file requires a Stream. - Stream^ reader = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - /* Use the Deserialize method to restore the object's state - using data from the XML document. */ - i = dynamic_cast(serializer->Deserialize( reader )); - - // Write out the properties of the object. - Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal ); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); - DeserializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp deleted file mode 100644 index 1774c451ee4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With XmlTextWriter" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlTextWriter using a FileStream. - Stream^ fs = gcnew FileStream( filename,FileMode::Create ); - XmlWriter^ writer = gcnew XmlTextWriter( fs,Encoding::Unicode ); - - // Serialize using the XmlTextWriter. - serializer->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp deleted file mode 100644 index 8a82ba5a382..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With XmlTextWriter" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlSerializerNamespaces object. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Add two namespaces with prefixes. - ns->Add( "inventory", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create an XmlTextWriter using a FileStream. - Stream^ fs = gcnew FileStream( filename,FileMode::Create ); - XmlWriter^ writer = gcnew XmlTextWriter( fs,gcnew UTF8Encoding ); - - // Serialize using the XmlTextWriter. - serializer->Serialize( writer, i, ns ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp deleted file mode 100644 index cef506f6c43..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - String^ GroupName; -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - - // Deserialize the file containing unknown elements. - t->DeserializeObject( "UnknownAttributes.xml" ); - } - -private: - void Serializer_UnknownAttribute( Object^ sender, XmlAttributeEventArgs^ e ) - { - Console::WriteLine( "Unknown Attribute" ); - Console::WriteLine( "\t{0} {1}", e->Attr->Name, e->Attr->InnerXml ); - Console::WriteLine( "\t LineNumber: {0}", e->LineNumber ); - Console::WriteLine( "\t LinePosition: {0}", e->LinePosition ); - Group^ x = dynamic_cast(e->ObjectBeingDeserialized); - Console::WriteLine( x->GroupName ); - Console::WriteLine( sender ); - } - - void DeserializeObject( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // Add a delegate to handle unknown element events. - ser->UnknownAttribute += gcnew XmlAttributeEventHandler( this, &Test::Serializer_UnknownAttribute ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = dynamic_cast(ser->Deserialize( fs )); - fs->Close(); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp deleted file mode 100644 index 57d80144134..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp +++ /dev/null @@ -1,79 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Group -{ -public: - - // Only the GroupName field will be known. - String^ GroupName; -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - t->DeserializeObject( "UnknownNodes.xml" ); - } - -private: - void DeserializeObject( String^ filename ) - { - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - mySerializer->UnknownNode += gcnew XmlNodeEventHandler( this, &Test::serializer_UnknownNode ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - fs->Close(); - } - -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Name: {0}", e->Name ); - Console::WriteLine( "UnknownNode LocalName: {0}", e->LocalName ); - Console::WriteLine( "UnknownNode Namespace URI: {0}", e->NamespaceURI ); - Console::WriteLine( "UnknownNode Text: {0}", e->Text ); - XmlNodeType myNodeType = e->NodeType; - Console::WriteLine( "NodeType: {0}", myNodeType ); - Group^ myGroup = dynamic_cast(e->ObjectBeingDeserialized); - Console::WriteLine( "GroupName: {0}", myGroup->GroupName ); - Console::WriteLine(); - } -}; - -int main() -{ - Test::main(); -} - -/* Paste this XML into a file named UnknownNodes: - - - MyGroup - Large - 444 - West - - 1 - Thing1 - - element - - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp deleted file mode 100644 index 1df7c03435e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp +++ /dev/null @@ -1,181 +0,0 @@ - - -// -// Beginning of the HighSchool.dll -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -namespace HighSchool -{ - public ref class Student - { - public: - String^ Name; - int ID; - }; - - public ref class MyClass - { - public: - array^Students; - }; -} - -namespace College -{ - -using namespace HighSchool; - public ref class Graduate: public HighSchool::Student - { - public: - Graduate(){} - - // Add a new field named University. - String^ University; - - // Use extra types to use this field. - array^Info; - }; - - public ref class Address - { - public: - String^ City; - }; - - public ref class Phone - { - public: - String^ Number; - }; - - public ref class Run - { - public: - static void main() - { - Run^ test = gcnew Run; - test->WriteOverriddenAttributes( "College.xml" ); - test->ReadOverriddenAttributes( "College.xml" ); - } - - private: - void WriteOverriddenAttributes( String^ filename ) - { - // Writing the file requires a TextWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - // Create an XMLAttributeOverrides class. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - // Create the XmlAttributes class. - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Override the Student class. "Alumni" is the name - of the overriding element in the XML output. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - - /* Add the XmlElementAttribute to the collection of - elements in the XmlAttributes object. */ - attrs->XmlElements->Add( attr ); - - /* Add the XmlAttributes to the XmlAttributeOverrides. - "Students" is the name being overridden. */ - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - - // Create array of extra types. - array^extraTypes = gcnew array(2); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - - // Create an XmlRootAttribute. - XmlRootAttribute^ root = gcnew XmlRootAttribute( "Graduates" ); - - /* Create the XmlSerializer with the - XmlAttributeOverrides object. */ - XmlSerializer^ mySerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides,extraTypes,root,"http://www.microsoft.com" ); - MyClass ^ myClass = gcnew MyClass; - Graduate^ g1 = gcnew Graduate; - g1->Name = "Jacki"; - g1->ID = 1; - g1->University = "Alma"; - Graduate^ g2 = gcnew Graduate; - g2->Name = "Megan"; - g2->ID = 2; - g2->University = "CM"; - array^myArray = {g1,g2}; - myClass->Students = myArray; - - // Create extra information. - Address^ a1 = gcnew Address; - a1->City = "Ionia"; - Address^ a2 = gcnew Address; - a2->City = "Stamford"; - Phone^ p1 = gcnew Phone; - p1->Number = "555-0101"; - Phone^ p2 = gcnew Phone; - p2->Number = "555-0100"; - array^o1 = {a1,p1}; - array^o2 = {a2,p2}; - g1->Info = o1; - g2->Info = o2; - mySerializer->Serialize( myStreamWriter, myClass ); - myStreamWriter->Close(); - } - - void ReadOverriddenAttributes( String^ filename ) - { - /* The majority of the code here is the same as that in the - WriteOverriddenAttributes method. Because the XML being read - doesn't conform to the schema defined by the DLL, the - XMLAttributesOverrides must be used to create an - XmlSerializer instance to read the XML document.*/ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - attrs->XmlElements->Add( attr ); - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - array^extraTypes = gcnew array(2); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - XmlRootAttribute^ root = gcnew XmlRootAttribute( "Graduates" ); - XmlSerializer^ readSerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides,extraTypes,root,"http://www.microsoft.com" ); - - // A FileStream object is required to read the file. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - MyClass ^ myClass; - myClass = dynamic_cast(readSerializer->Deserialize( fs )); - - /* Here is the difference between reading and writing an - XML document: You must declare an object of the derived - type (Graduate) and cast the Student instance to it.*/ - Graduate^ g; - Address^ a; - Phone^ p; - System::Collections::IEnumerator^ myEnum = myClass->Students->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Graduate^ grad = safe_cast(myEnum->Current); - g = dynamic_cast(grad); - Console::Write( "{0}\t", g->Name ); - Console::Write( "{0}\t", g->ID ); - Console::Write( "{0}\n", g->University ); - a = dynamic_cast(g->Info[ 0 ]); - Console::WriteLine( a->City ); - p = dynamic_cast(g->Info[ 1 ]); - Console::WriteLine( p->Number ); - } - } - }; -} - -int main() -{ - College::Run::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp deleted file mode 100644 index 173d91e6ff3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Class1 -{ - // -private: - void SerializeObject( String^ filename ) - { - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,"http://www.cpandl.com" ); - - // Create an instance of the class to be serialized. - OrderedItem^ i = gcnew OrderedItem; - - // Insert code to set property values. - - // Writing the document requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - // Serialize the object, and close the TextWriter - serializer->Serialize( writer, i ); - writer->Close(); - } - - void DeserializeObject( String^ filename ) - { - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,"http://www.cpandl.com" ); - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Deserialize the object. - i = dynamic_cast(serializer->Deserialize( fs )); - - // Insert code to use the properties and methods of the object. - } - // - -public: - ref class OrderedItem{ - // Members of OrderedItem go here - }; -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp deleted file mode 100644 index 2ce08d9f7a1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Class1 -{ - // -private: - void SerializeObject( String^ filename ) - { - // Create an XmlRootAttribute, and set its properties. - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - xRoot->ElementName = "CustomRoot"; - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->IsNullable = true; - - // Construct the XmlSerializer with the XmlRootAttribute. - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,xRoot ); - - // Create an instance of the object to serialize. - OrderedItem^ i = gcnew OrderedItem; - // Insert code to set properties of the ordered item. - - // Writing the document requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - serializer->Serialize( writer, i ); - writer->Close(); - } - - void DeserializeObject( String^ filename ) - { - // Create an XmlRootAttribute, and set its properties. - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - xRoot->ElementName = "CustomRoot"; - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->IsNullable = true; - - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,xRoot ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - // Deserialize the object. - OrderedItem^ i = dynamic_cast(serializer->Deserialize( fs )); - // Insert code to use the object's properties and methods. - } - // - -public: - ref class OrderedItem{ - // Members of OrderedItem go here - }; -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp deleted file mode 100644 index 669af6e0644..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp +++ /dev/null @@ -1,137 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -ref class Address; -ref class Phone; - -// This defines the object that will be serialized. -public ref class Teacher -{ -public: - String^ Name; - Teacher(){} - - /* Note that the Info field returns an array of objects. - Any object can be added to the array by adding the - object type to the array passed to the extraTypes argument. */ - - [XmlArray(ElementName="ExtraInfo",IsNullable=true)] - array^Info; - Phone^ PhoneInfo; -}; - - -// This defines one of the extra types to be included. -public ref class Address -{ -public: - String^ City; - Address(){} - - Address( String^ city ) - { - City = city; - } -}; - -// Another extra type to include. -public ref class Phone -{ -public: - String^ PhoneNumber; - Phone(){} - - Phone( String^ phoneNumber ) - { - PhoneNumber = phoneNumber; - } -}; - -// Another type, derived from Phone -public ref class InternationalPhone: public Phone -{ -public: - String^ CountryCode; - InternationalPhone(){} - - InternationalPhone( String^ countryCode ) - { - CountryCode = countryCode; - } -}; - -public ref class Run -{ -public: - static void main() - { - Run^ test = gcnew Run; - test->SerializeObject( "Teacher.xml" ); - test->DeserializeObject( "Teacher.xml" ); - } - -private: - void SerializeObject( String^ filename ) - { - // Writing the file requires a TextWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - // Create a Type array. - array^extraTypes = gcnew array(3); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - extraTypes[ 2 ] = InternationalPhone::typeid; - - // Create the XmlSerializer instance. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Teacher::typeid,extraTypes ); - Teacher^ teacher = gcnew Teacher; - teacher->Name = "Mike"; - - // Add extra types to the Teacher object - array^info = gcnew array(2); - info[ 0 ] = gcnew Address( "Springville" ); - info[ 1 ] = gcnew Phone( "555-0100" ); - teacher->Info = info; - teacher->PhoneInfo = gcnew InternationalPhone( "000" ); - mySerializer->Serialize( myStreamWriter, teacher ); - myStreamWriter->Close(); - } - - void DeserializeObject( String^ filename ) - { - // Create a Type array. - array^extraTypes = gcnew array(3); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - extraTypes[ 2 ] = InternationalPhone::typeid; - - // Create the XmlSerializer instance. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Teacher::typeid,extraTypes ); - - // Reading a file requires a FileStream. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Teacher^ teacher = dynamic_cast(mySerializer->Deserialize( fs )); - - // Read the extra information. - Address^ a = dynamic_cast(teacher->Info[ 0 ]); - Phone^ p = dynamic_cast(teacher->Info[ 1 ]); - InternationalPhone^ Ip = dynamic_cast(teacher->PhoneInfo); - Console::WriteLine( teacher->Name ); - Console::WriteLine( a->City ); - Console::WriteLine( p->PhoneNumber ); - Console::WriteLine( Ip->CountryCode ); - } -}; - -int main() -{ - Run::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp deleted file mode 100644 index 0050ba6a3ce..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp +++ /dev/null @@ -1,133 +0,0 @@ - - -// -// Beginning of HighSchool.dll -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -namespace HighSchool -{ - public ref class Student - { - public: - String^ Name; - int ID; - }; - - public ref class MyClass - { - public: - array^Students; - }; -} - -namespace College -{ - -using namespace HighSchool; - public ref class Graduate: public HighSchool::Student - { - public: - Graduate(){} - - // Add a new field named University. - String^ University; - }; - - public ref class Run - { - public: - static void main() - { - Run^ test = gcnew Run; - test->WriteOverriddenAttributes( "College.xml" ); - test->ReadOverriddenAttributes( "College.xml" ); - } - - private: - void WriteOverriddenAttributes( String^ filename ) - { - // Writing the file requires a TextWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - // Create an XMLAttributeOverrides class. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - // Create the XmlAttributes class. - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Override the Student class. "Alumni" is the name - of the overriding element in the XML output. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - - /* Add the XmlElementAttribute to the collection of - elements in the XmlAttributes object. */ - attrs->XmlElements->Add( attr ); - - /* Add the XmlAttributes to the XmlAttributeOverrides. - "Students" is the name being overridden. */ - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - - // Create the XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides ); - MyClass ^ myClass = gcnew MyClass; - Graduate^ g1 = gcnew Graduate; - g1->Name = "Jackie"; - g1->ID = 1; - g1->University = "Alma Mater"; - Graduate^ g2 = gcnew Graduate; - g2->Name = "Megan"; - g2->ID = 2; - g2->University = "CM"; - array^myArray = {g1,g2}; - myClass->Students = myArray; - mySerializer->Serialize( myStreamWriter, myClass ); - myStreamWriter->Close(); - } - - void ReadOverriddenAttributes( String^ filename ) - { - /* The majority of the code here is the same as that in the - WriteOverriddenAttributes method. Because the XML being read - doesn't conform to the schema defined by the DLL, the - XMLAttributesOverrides must be used to create an - XmlSerializer instance to read the XML document.*/ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - attrs->XmlElements->Add( attr ); - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - XmlSerializer^ readSerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides ); - - // To read the file, a FileStream object is required. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - MyClass ^ myClass; - myClass = dynamic_cast(readSerializer->Deserialize( fs )); - - /* Here is the difference between reading and writing an - XML document: You must declare an object of the derived - type (Graduate) and cast the Student instance to it.*/ - Graduate^ g; - System::Collections::IEnumerator^ myEnum = myClass->Students->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Graduate^ grad = safe_cast(myEnum->Current); - g = dynamic_cast(grad); - Console::Write( "{0}\t", g->Name ); - Console::Write( "{0}\t", g->ID ); - Console::Write( "{0}\n", g->University ); - } - } - }; -} - -int main() -{ - College::Run::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp deleted file mode 100644 index 6dabc064fb4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void SerializeObject( String^ filename ) - { - XmlSerializer^ serializer = - gcnew XmlSerializer( OrderedItem::typeid ); - - // Create an instance of the class to be serialized. - OrderedItem^ i = gcnew OrderedItem; - - // Set the public property values. - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - - // Writing the document requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Serialize the object, and close the TextWriter. - serializer->Serialize( writer, i ); - writer->Close(); - } - -public: - // This is the class that will be serialized. - ref class OrderedItem - { - public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - }; - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp deleted file mode 100644 index 01f91598da8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp +++ /dev/null @@ -1,82 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Price -{ -public: - - [XmlAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ currency; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal price; -}; - -[XmlType(Namespace="http://www.cpandl.com")] -public ref class Book -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ TITLE; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Price^ PRICE; -}; - -public ref class Books -{ -public: - - [XmlElement(Namespace="http://www.cohowinery.com")] - Book^ Book; -}; - -public ref class Run -{ -public: - static void main() - { - Run^ test = gcnew Run; - test->SerializeObject( "XmlNamespaces.xml" ); - } - - void SerializeObject( String^ filename ) - { - XmlSerializer^ s = gcnew XmlSerializer( Books::typeid ); - - // Writing a file requires a TextWriter. - TextWriter^ t = gcnew StreamWriter( filename ); - - /* Create an XmlSerializerNamespaces object and add two - prefix-namespace pairs. */ - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - ns->Add( "books", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create a Book instance. - Book^ b = gcnew Book; - b->TITLE = "A Book Title"; - Price^ p = gcnew Price; - p->price = (Decimal)9.95; - p->currency = "US Dollar"; - b->PRICE = p; - Books^ bks = gcnew Books; - bks->Book = b; - s->Serialize( t, bks, ns ); - t->Close(); - } -}; - -int main() -{ - Run::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp deleted file mode 100644 index 825b960ef4a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - XmlSerializerNamespaces^ AddNamespaces() - { - XmlSerializerNamespaces^ xmlNamespaces = - gcnew XmlSerializerNamespaces; - - // Add three prefix-namespace pairs. - xmlNamespaces->Add( "money", "http://www.cpandl.com" ); - xmlNamespaces->Add( "books", "http://www.cohowinery.com" ); - xmlNamespaces->Add( "software", "http://www.microsoft.com" ); - - return xmlNamespaces; - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp deleted file mode 100644 index 89a101a18a2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void PrintNamespacePairs( XmlSerializerNamespaces^ namespaces ) - { - array^ qualifiedNames = namespaces->ToArray(); - for ( int i = 0; i < qualifiedNames->Length; i++ ) - { - Console::WriteLine( "{0}\t{1}", - qualifiedNames[ i ]->Name, qualifiedNames[ i ]->Namespace ); - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp deleted file mode 100644 index 58d5dd55649..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - XmlSerializerNamespaces^ CreateFromQNames() - { - XmlQualifiedName^ q1 = - gcnew XmlQualifiedName( "money","http://www.cohowinery.com" ); - - XmlQualifiedName^ q2 = - gcnew XmlQualifiedName( "books","http://www.cpandl.com" ); - - array^ names = { q1, q2 }; - - return gcnew XmlSerializerNamespaces( names ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp deleted file mode 100644 index fadecdb274e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,99 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml::Serialization; -using namespace System::IO; - -public ref class Group1 -{ -public: - - // The XmlTextAttribute with type set to string informs the - // XmlSerializer that strings should be serialized as XML text. - - [XmlText(String::typeid)] - [XmlElement(Int32::typeid)] - [XmlElement(Double::typeid)] - array^All; - Group1() - { - array^temp = {321,"One",2,3.0,"Two"}; - All = temp; - } -}; - -public enum class GroupType -{ - Small, Medium, Large -}; - -public ref class Group2 -{ -public: - - [XmlText(Type=GroupType::typeid)] - GroupType Type; -}; - -public ref class Group3 -{ -public: - - [XmlText(Type=DateTime::typeid)] - DateTime CreationTime; - Group3() - { - CreationTime = DateTime::Now; - } -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - t->SerializeArray( "XmlText1.xml" ); - t->SerializeEnum( "XmlText2.xml" ); - t->SerializeDateTime( "XmlText3.xml" ); - } - -private: - void SerializeArray( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group1::typeid ); - Group1^ myGroup1 = gcnew Group1; - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup1 ); - writer->Close(); - } - - void SerializeEnum( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group2::typeid ); - Group2^ myGroup = gcnew Group2; - myGroup->Type = GroupType::Medium; - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup ); - writer->Close(); - } - - void SerializeDateTime( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group3::typeid ); - Group3^ myGroup = gcnew Group3; - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup ); - writer->Close(); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp deleted file mode 100644 index d6719698f71..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - String^ GroupName; - String^ Comment; -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - t->SerializerOrder( "TextOverride.xml" ); - } - - /* Create an instance of the XmlSerializer class that overrides - the default way it serializes an object. */ - XmlSerializer^ CreateOverrider() - { - /* Create instances of the XmlAttributes and - XmlAttributeOverrides classes. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlTextAttribute to override the default - serialization process. */ - XmlTextAttribute^ xText = gcnew XmlTextAttribute; - attrs->XmlText = xText; - - // Add the XmlAttributes to the XmlAttributeOverrides. - xOver->Add( Group::typeid, "Comment", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } - - void SerializerOrder( String^ filename ) - { - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object and serialize it. - Group^ myGroup = gcnew Group; - myGroup->Comment = "This is a great product."; - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myGroup ); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp deleted file mode 100644 index 0b402e1de87..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlType(Namespace="http://www.cpandl.com", -TypeName="GroupMember")] -public ref class Person -{ -public: - String^ Name; -}; - - -[XmlType(Namespace="http://www.cohowinery.com", -TypeName="GroupAddress")] -public ref class Address -{ -public: - String^ Line1; - String^ Line2; - String^ City; - String^ State; - String^ Zip; -}; - -public ref class Group -{ -public: - array^Staff; - Person^ Manager; - Address^ Location; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp deleted file mode 100644 index 592b8ccb053..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlType(IncludeInSchema=false)] -public ref class ExtraneousInfo{}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 04919033ae5..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlType(Namespace="http://www.cpandl.com")] -public ref class Book{}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp deleted file mode 100644 index 87847fcbb3e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -ref class Person; -ref class Job; -ref class Group -{ -public: - array^Staff; -}; - - -[XmlType(TypeName="Employee", -Namespace="http://www.cpandl.com")] -public ref class Person -{ -public: - String^ PersonName; - Job^ Position; -}; - - -[XmlType(TypeName="Occupation", -Namespace="http://www.cohowinery.com")] -public ref class Job -{ -public: - String^ JobName; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp b/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp deleted file mode 100644 index 1418ec5d414..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; - -public ref class Forest -{ - // Set the NestingLevel for each array. The first - // attribute (NestingLevel = 0) is optional. -public: - [XmlArrayItem(ElementName = "tree", NestingLevel = 0)] - [XmlArrayItem(ElementName = "branch", NestingLevel = 1)] - [XmlArrayItem(ElementName = "leaf",NestingLevel = 2)] - array^>^>^ TreeArray; -}; - -int main() -{ - XmlSerializer^ serializer = gcnew XmlSerializer(Forest::typeid); - - Forest^ constructedForest = gcnew Forest(); - array^>^>^ tree = - gcnew array^>^>(2); - - array^>^ firstBranch = gcnew array^>(1); - firstBranch[0] = gcnew array{"One"}; - tree[0] = firstBranch; - - array^>^ secondBranch = gcnew array^>(2); - secondBranch[0] = gcnew array{"One","Two"}; - secondBranch[1] = gcnew array{"One","Two","Three"}; - tree[1] = secondBranch; - - constructedForest->TreeArray = tree; - - serializer->Serialize(Console::Out, constructedForest); -} - -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp deleted file mode 100644 index 076a9f19088..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp +++ /dev/null @@ -1,126 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; -using namespace System::ComponentModel; -public ref class Group -{ -public: - - // The default is set to .NET. - - [DefaultValue(".NET")] - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Setting the GroupName to '.NET' is like not setting it at all - // because it is the default value. So no value will be - // serialized, and on deserialization it will appear as a blank. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); - } - - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // The specifies that the default value is now - // 'Team1'. So setting the GroupName to '.NET' means - // the value will be serialized. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - - void DeserializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Reading the file requires a TextReader. - TextReader^ reader = gcnew StreamReader( filename ); - - // Deserialize and cast the Object*. - Group^ myGroup; - myGroup = safe_cast(mySerializer->Deserialize( reader )); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine(); - } - - void DeserializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Reading the file requires a TextReader. - TextReader^ reader = gcnew StreamReader( filename ); - - // Deserialize and cast the Object*. - Group^ myGroup; - myGroup = safe_cast(overRideSerializer->Deserialize( reader )); - Console::WriteLine( myGroup->GroupName ); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ soapAtts = gcnew SoapAttributes; - - // Create a new DefaultValueAttribute Object* for the GroupName - // property. - DefaultValueAttribute^ newDefault = gcnew DefaultValueAttribute( "Team1" ); - soapAtts->SoapDefaultValue = newDefault; - mySoapAttributeOverrides->Add( Group::typeid, "GroupName", soapAtts ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer Object*. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOriginal( "SoapOriginal.xml" ); - test->SerializeOverride( "mySoapAttributeOverridesideAttributes.xml" ); - test->DeserializeOriginal( "SoapOriginal.xml" ); - test->DeserializeOverride( "mySoapAttributeOverridesideAttributes.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp deleted file mode 100644 index 6c2fca3bb4d..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp +++ /dev/null @@ -1,115 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -//using namespace System::Runtime::Remoting::Metadata; -public ref class Vehicle -{ -public: - String^ licenseNumber; -}; - - -[SoapInclude(Vehicle::typeid)] -public ref class Group -{ -public: - - [SoapAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; - - [SoapAttributeAttribute(DataType="base64Binary")] - array^GroupNumber; - - [SoapAttributeAttribute(DataType="date",AttributeName="CreationDate")] - DateTime Today; - - [SoapElement(DataType="nonNegativeInteger",ElementName="PosInt")] - String^ PostitiveInt; - Vehicle^ GroupVehicle; -}; - -public ref class Run -{ -public: - void SerializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // can generate encoded SOAP messages. - XmlSerializer^ mySerializer = ReturnSOAPSerializer(); - Group^ myGroup = MakeGroup(); - - // Writing the file requires a TextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->WriteEndElement(); - writer->Close(); - } - - -private: - Group^ MakeGroup() - { - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - array^hexByte = {Convert::ToByte( 100 ),Convert::ToByte( 50 )}; - myGroup->GroupNumber = hexByte; - DateTime myDate = DateTime(2002,5,2); - myGroup->Today = myDate; - myGroup->PostitiveInt = "10000"; - myGroup->GroupVehicle = gcnew Vehicle; - myGroup->GroupVehicle->licenseNumber = "1234"; - return myGroup; - } - -public: - void DeserializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // can generate encoded SOAP messages. - XmlSerializer^ mySerializer = ReturnSOAPSerializer(); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement( "wrapper" ); - - // Deserialize and cast the Object*. - Group^ myGroup; - myGroup = safe_cast(mySerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - } - -private: - XmlSerializer^ ReturnSOAPSerializer() - { - - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - return gcnew XmlSerializer( myMapping ); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeObject( "SoapAtts.xml" ); - test->DeserializeObject( "SoapAtts.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp deleted file mode 100644 index ca2b9a2176d..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp +++ /dev/null @@ -1,76 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Group -{ -public: - - // This attribute will be overridden. - - [SoapAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ mySoapAttributes = gcnew SoapAttributes; - - // Create a new SoapAttributeAttribute to the - // one applied to the Group class. The resulting XML - // stream will use the new namespace and attribute name. - SoapAttributeAttribute^ mySoapAttribute = gcnew SoapAttributeAttribute; - mySoapAttribute->AttributeName = "TeamName"; - - // Change the Namespace. - mySoapAttribute->Namespace = "http://www.cohowinery.com"; - mySoapAttributes->SoapAttribute = mySoapAttribute; - mySoapAttributeOverrides->Add( Group::typeid, "GroupName", mySoapAttributes ); - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOverride( "SoapOveride.xml" ); -} - -// -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp deleted file mode 100644 index 723d53337e0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Group -{ -public: - // Override the serialization of this member. - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ mySoapAttributes = gcnew SoapAttributes; - SoapElementAttribute^ mySoapElement = gcnew SoapElementAttribute; - mySoapElement->ElementName = "TeamName"; - mySoapAttributes->SoapElement = mySoapElement; - - // Add the SoapAttributes to the - // mySoapAttributeOverridesrides object. - mySoapAttributeOverrides->Add( Group::typeid, "GroupName", mySoapAttributes ); - - // Get the SoapAttributes with the Item property. - SoapAttributes^ thisSoapAtts = mySoapAttributeOverrides[Group::typeid, "GroupName"]; - Console::WriteLine( "New serialized element name: {0}", thisSoapAtts->SoapElement->ElementName ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer object. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))-> - ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOverride( "GetSoapAttributes.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp deleted file mode 100644 index e35e9d519f2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// The name of this type will be overridden using -// the SoapTypeAttribute. -public ref class Group -{ -public: - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ mySoapAttributes = gcnew SoapAttributes; - SoapTypeAttribute^ mySoapType = gcnew SoapTypeAttribute; - mySoapType->TypeName = "Team"; - mySoapAttributes->SoapType = mySoapType; - - // Add the SoapAttributes to the - // mySoapAttributeOverridesrides object. - mySoapAttributeOverrides->Add( Group::typeid, mySoapAttributes ); - - // Get the SoapAttributes with the Item property. - SoapAttributes^ thisSoapAtts = mySoapAttributeOverrides[ Group::typeid ]; - Console::WriteLine( "New serialized type name: {0}", thisSoapAtts->SoapType->TypeName ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer object. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))-> - ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOverride( "GetSoapAttributes2.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp deleted file mode 100644 index cd4ad348629..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp +++ /dev/null @@ -1,246 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; -ref class Car; - -// SoapInclude allows Vehicle to accept Car type. - -[SoapInclude(Car::typeid)] -public ref class Vehicle abstract -{ -public: - String^ licenseNumber; - DateTime makeDate; -}; - -public ref class Car: public Vehicle{}; - -public enum class GroupType -{ - // These enums can be overridden. - [SoapEnum("Small")] - A, - [SoapEnum("Large")] - B -}; - -public ref class Group -{ -public: - - [SoapAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; - - [SoapAttributeAttribute(DataType="base64Binary")] - array^GroupNumber; - - [SoapAttributeAttribute(DataType="date",AttributeName="CreationDate")] - DateTime Today; - - [SoapElement(DataType="nonNegativeInteger",ElementName="PosInt")] - String^ PostitiveInt; - - // This is ignored when serialized unless it's overridden. - - [SoapIgnore] - bool IgnoreThis; - GroupType Grouptype; - Vehicle^ MyVehicle; - - // The SoapInclude allows the method to return a Car. - - [SoapInclude(Car::typeid)] - Vehicle^ myCar( String^ licNumber ) - { - Vehicle^ v; - if ( licNumber->Equals( "" ) ) - { - v = gcnew Car; - v->licenseNumber = "!!!!!!"; - } - else - { - v = gcnew Car; - v->licenseNumber = licNumber; - } - - return v; - } -}; - -public ref class Run -{ -public: - static void main() - { - Run^ test = gcnew Run; - test->SerializeOriginal( "SoapOriginal.xml" ); - test->SerializeOverride( "SoapOverrides.xml" ); - test->DeserializeOriginal( "SoapOriginal.xml" ); - test->DeserializeOverride( "SoapOverrides.xml" ); - } - - void SerializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( myMapping ); - Group^ myGroup = MakeGroup(); - - // Writing the file requires a TextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->WriteEndElement(); - writer->Close(); - } - - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - Group^ myGroup = MakeGroup(); - - // Writing the file requires a TextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->WriteEndElement(); - writer->Close(); - } - -private: - Group^ MakeGroup() - { - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - array^hexByte = {Convert::ToByte( 100 ),Convert::ToByte( 50 )}; - myGroup->GroupNumber = hexByte; - DateTime myDate = DateTime(2002,5,2); - myGroup->Today = myDate; - myGroup->PostitiveInt = "10000"; - myGroup->IgnoreThis = true; - myGroup->Grouptype = GroupType::B; - Car^ thisCar = dynamic_cast(myGroup->myCar( "1234566" )); - myGroup->MyVehicle = thisCar; - return myGroup; - } - -public: - void DeserializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( myMapping ); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement( "wrapper" ); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(mySerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - } - - void DeserializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement( "wrapper" ); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(overRideSerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - ReadGroup( myGroup ); - } - -private: - void ReadGroup( Group^ myGroup ) - { - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( myGroup->GroupNumber[ 0 ] ); - Console::WriteLine( myGroup->GroupNumber[ 1 ] ); - Console::WriteLine( myGroup->Today ); - Console::WriteLine( myGroup->PostitiveInt ); - Console::WriteLine( myGroup->IgnoreThis ); - Console::WriteLine(); - } - - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ soapAtts = gcnew SoapAttributes; - SoapElementAttribute^ mySoapElement = gcnew SoapElementAttribute; - mySoapElement->ElementName = "xxxx"; - soapAtts->SoapElement = mySoapElement; - mySoapAttributeOverrides->Add( Group::typeid, "PostitiveInt", soapAtts ); - - // Override the IgnoreThis property. - SoapIgnoreAttribute^ myIgnore = gcnew SoapIgnoreAttribute; - soapAtts = gcnew SoapAttributes; - soapAtts->SoapIgnore = false; - mySoapAttributeOverrides->Add( Group::typeid, "IgnoreThis", soapAtts ); - - // Override the GroupType enumeration. - soapAtts = gcnew SoapAttributes; - SoapEnumAttribute^ xSoapEnum = gcnew SoapEnumAttribute; - xSoapEnum->Name = "Over1000"; - soapAtts->GroupType::SoapEnum = xSoapEnum; - - // Add the SoapAttributes to the - // mySoapAttributeOverridesrides object. - mySoapAttributeOverrides->Add( GroupType::typeid, "A", soapAtts ); - - // Create second enumeration and add it. - soapAtts = gcnew SoapAttributes; - xSoapEnum = gcnew SoapEnumAttribute; - xSoapEnum->Name = "ZeroTo1000"; - soapAtts->GroupType::SoapEnum = xSoapEnum; - mySoapAttributeOverrides->Add( GroupType::typeid, "B", soapAtts ); - - // Override the Group type. - soapAtts = gcnew SoapAttributes; - SoapTypeAttribute^ soapType = gcnew SoapTypeAttribute; - soapType->TypeName = "Team"; - soapAtts->SoapType = soapType; - mySoapAttributeOverrides->Add( Group::typeid, soapAtts ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer object. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp deleted file mode 100644 index bbc969c59c5..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp +++ /dev/null @@ -1,106 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Text; -public ref class Thing -{ -public: - - [SoapElement(IsNullable=true)] - String^ ThingName; -}; - -public ref class Transportation -{ -public: - - // The SoapElementAttribute specifies that the - // generated XML element name will be S"Wheels" - // instead of S"Vehicle". - - [SoapElement("Wheels")] - String^ Vehicle; - - [SoapElement(DataType="dateTime")] - DateTime CreationDate; - - [SoapElement(IsNullable=true)] - Thing^ thing; -}; - -public ref class Test -{ -public: - - // Return an XmlSerializer used for overriding. - XmlSerializer^ CreateSoapOverrider() - { - // Create the SoapAttributes and SoapAttributeOverrides objects. - SoapAttributes^ soapAttrs = gcnew SoapAttributes; - SoapAttributeOverrides^ soapOverrides = gcnew SoapAttributeOverrides; - - // Create an SoapElementAttribute to the Vehicles property. - SoapElementAttribute^ soapElement1 = gcnew SoapElementAttribute( "Truck" ); - - // Set the SoapElement to the Object*. - soapAttrs->SoapElement = soapElement1; - - // Add the SoapAttributes to the SoapAttributeOverrides,specifying the member to. - soapOverrides->Add( Transportation::typeid, "Vehicle", soapAttrs ); - - // Create the XmlSerializer, and return it. - XmlTypeMapping^ myTypeMapping = (gcnew SoapReflectionImporter( soapOverrides ))->ImportTypeMapping( Transportation::typeid ); - return gcnew XmlSerializer( myTypeMapping ); - } - - void SerializeOverride( String^ filename ) - { - // Create an XmlSerializer instance. - XmlSerializer^ ser = CreateSoapOverrider(); - - // Create the Object* and serialize it. - Transportation^ myTransportation = gcnew Transportation; - myTransportation->Vehicle = "MyCar"; - myTransportation->CreationDate = DateTime::Now; - myTransportation->thing = gcnew Thing; - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - ser->Serialize( writer, myTransportation ); - writer->WriteEndElement(); - writer->Close(); - } - - void SerializeObject( String^ filename ) - { - // Create an XmlSerializer instance. - XmlSerializer^ ser = gcnew XmlSerializer( Transportation::typeid ); - Transportation^ myTransportation = gcnew Transportation; - myTransportation->Vehicle = "MyCar"; - myTransportation->CreationDate = DateTime::Now; - myTransportation->thing = gcnew Thing; - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - ser->Serialize( writer, myTransportation ); - writer->WriteEndElement(); - writer->Close(); - } -}; - -int main() -{ - Test^ t = gcnew Test; - t->SerializeObject( "SoapElementOriginal.xml" ); - t->SerializeOverride( "SoapElementOverride.xml" ); - Console::WriteLine( "Finished writing two XML files." ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp deleted file mode 100644 index a91c48a0ab8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp +++ /dev/null @@ -1,94 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public enum class GroupType -{ - // Use the SoapEnumAttribute to instruct the XmlSerializer - // to generate Small and Large instead of A and B. - [SoapEnum("Small")] - A, - [SoapEnum("Large")] - B -}; - -public ref class Group -{ -public: - String^ GroupName; - GroupType Grouptype; -}; - -public ref class Run -{ -public: - void SerializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer Class. - XmlTypeMapping^ mapp = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( mapp ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the Class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - myGroup->Grouptype = GroupType::A; - - // Serialize the Class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); - } - - void SerializeOverride( String^ fileName ) - { - SoapAttributeOverrides^ soapOver = gcnew SoapAttributeOverrides; - SoapAttributes^ SoapAtts = gcnew SoapAttributes; - - // Add a SoapEnumAttribute for the GroupType::A enumerator. - // Instead of 'A' it will be S"West". - SoapEnumAttribute^ soapEnum = gcnew SoapEnumAttribute( "West" ); - - // Override the S"A" enumerator. - SoapAtts->GroupType::SoapEnum = soapEnum; - soapOver->Add( GroupType::typeid, "A", SoapAtts ); - - // Add another SoapEnumAttribute for the GroupType::B enumerator. - // Instead of //B// it will be S"East". - SoapAtts = gcnew SoapAttributes; - soapEnum = gcnew SoapEnumAttribute; - soapEnum->Name = "East"; - SoapAtts->GroupType::SoapEnum = soapEnum; - soapOver->Add( GroupType::typeid, "B", SoapAtts ); - - // Create an XmlSerializer used for overriding. - XmlTypeMapping^ map = (gcnew SoapReflectionImporter( soapOver ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( map ); - Group^ myGroup = gcnew Group; - myGroup->GroupName = ".NET"; - myGroup->Grouptype = GroupType::B; - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( fileName ); - ser->Serialize( writer, myGroup ); - writer->Close(); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeObject( "SoapEnum.xml" ); - test->SerializeOverride( "SoapOverride.xml" ); - Console::WriteLine( "Fininished writing two files" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp deleted file mode 100644 index 1c316326d9c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp +++ /dev/null @@ -1,171 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -[SoapType("EmployeeType")] -public ref class Employee -{ -public: - String^ Name; -}; - - -// The SoapType is overridden when the -// SerializeOverride method is called. - -[SoapType("SoapGroupType","http://www.cohowinery.com")] -public ref class Group -{ -public: - String^ GroupName; - array^Employees; -}; - -public ref class Run -{ -public: - void SerializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // can be used for serializing as a SOAP message. - XmlTypeMapping^ mapp = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( mapp ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an XML text writer. - XmlTextWriter^ xmlWriter = gcnew XmlTextWriter( writer ); - xmlWriter->Formatting = Formatting::Indented; - xmlWriter->Indentation = 2; - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - Employee^ e1 = gcnew Employee; - e1->Name = "Pat"; - myGroup->Employees = gcnew array(1); - myGroup->Employees[ 0 ] = e1; - - // Write the root element. - xmlWriter->WriteStartElement( "root" ); - - // Serialize the class. - mySerializer->Serialize( xmlWriter, myGroup ); - - // Close the root tag. - xmlWriter->WriteEndElement(); - - // Close the XmlWriter. - xmlWriter->Close(); - - // Close the TextWriter. - writer->Close(); - } - - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // uses a SoapAttributeOverrides Object*. - XmlSerializer^ mySerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an XML text writer. - XmlTextWriter^ xmlWriter = gcnew XmlTextWriter( writer ); - xmlWriter->Formatting = Formatting::Indented; - xmlWriter->Indentation = 2; - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - Employee^ e1 = gcnew Employee; - e1->Name = "Pat"; - myGroup->Employees = gcnew array(1); - myGroup->Employees[ 0 ] = e1; - - // Write the root element. - xmlWriter->WriteStartElement( "root" ); - - // Serialize the class. - mySerializer->Serialize( xmlWriter, myGroup ); - - // Close the root tag. - xmlWriter->WriteEndElement(); - - // Close the XmlWriter. - xmlWriter->Close(); - - // Close the TextWriter. - writer->Close(); - } - - void DeserializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrideSerializer(); - - // Reading the file requires a TextReader. - TextReader^ reader = gcnew StreamReader( filename ); - - // Create an XML text reader. - XmlTextReader^ xmlReader = gcnew XmlTextReader( reader ); - xmlReader->ReadStartElement(); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(mySerializer->Deserialize( xmlReader )); - xmlReader->ReadEndElement(); - Console::WriteLine( "The GroupName is {0}", myGroup->GroupName ); - Console::WriteLine( "Look at the SoapType.xml and SoapType2.xml " - "files for the generated XML." ); - - // Close the readers. - xmlReader->Close(); - reader->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - // Create and return an XmlSerializer instance used to - // and create SOAP messages. - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ soapAtts = gcnew SoapAttributes; - - // Override the SoapTypeAttribute. - SoapTypeAttribute^ soapType = gcnew SoapTypeAttribute; - soapType->TypeName = "Team"; - soapType->IncludeInSchema = false; - soapType->Namespace = "http://www.microsoft.com"; - soapAtts->SoapType = soapType; - mySoapAttributeOverrides->Add( Group::typeid, soapAtts ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer Object*. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOriginal( "SoapType.xml" ); - test->SerializeOverride( "SoapType2.xml" ); - test->DeserializeObject( "SoapType2.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp b/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp deleted file mode 100644 index 0f5bd7c7799..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp +++ /dev/null @@ -1,90 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -ref class Vehicle; - -[SoapInclude(Vehicle::typeid)] -public ref class Vehicle -{ -public: - String^ licenseNumber; -}; - - -// You must use the SoapIncludeAttribute to inform the XmlSerializer -// that the Vehicle type should be recognized when deserializing. - -[SoapInclude(Vehicle::typeid)] -public ref class Group -{ -public: - String^ GroupName; - Vehicle^ GroupVehicle; -}; - -public ref class Run -{ -public: - void DeserializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = ((gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid )); - XmlSerializer^ mySerializer = gcnew XmlSerializer( myMapping ); - mySerializer->UnreferencedObject += gcnew UnreferencedObjectEventHandler( this, &Run::Serializer_UnreferencedObject ); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement(); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(mySerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - } - -private: - void Serializer_UnreferencedObject( Object^ /*sender*/, UnreferencedObjectEventArgs^ e ) - { - Console::WriteLine( "UnreferencedObject:" ); - Console::WriteLine( "ID: {0}", e->UnreferencedId ); - Console::WriteLine( "UnreferencedObject: {0}", e->UnreferencedObject ); - Vehicle^ myVehicle = dynamic_cast(e->UnreferencedObject); - Console::WriteLine( "License: {0}", myVehicle->licenseNumber ); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->DeserializeObject( "UnrefObj.xml" ); -} - -// The file named S"UnrefObj.xml" should contain this XML: -// -// -// -// -// ABCD -// -// -// 1234 -// -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XMLAttributeAttribute_ctr1_2/CPP/xmlAttributeAttribute_ctr1_2.cpp b/snippets/cpp/VS_Snippets_Remoting/XMLAttributeAttribute_ctr1_2/CPP/xmlAttributeAttribute_ctr1_2.cpp deleted file mode 100644 index 165da0b159e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XMLAttributeAttribute_ctr1_2/CPP/xmlAttributeAttribute_ctr1_2.cpp +++ /dev/null @@ -1,100 +0,0 @@ - - -// System.Xml.Serialization.XmlAttributeAttribute.XmlAttributeAttribute() -// System.Xml.Serialization.XmlAttributeAttribute.XmlAttributeAttribute(String) -/* The following example demonstrates the XmlAttributeAttribute constructor. -* This sample serializes a class named 'Student'. The StudentName property is -* serialized as an XML attribute. It also serializes a class named 'Book'. -*/ -// -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Student -{ -public: - String^ StudentName; - int StudentNumber; -}; - -public ref class Book -{ -public: - String^ BookName; - int BookNumber; -}; - -void SerializeObject( String^ studentFilename, String^ bookFilename ) -{ - XmlSerializer^ mySerializer; - TextWriter^ writer; - - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ myXmlAttributeOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ myXmlAttributes = gcnew XmlAttributes; - - /* Create an XmlAttributeAttribute set it to - the XmlAttribute property of the XmlAttributes object.*/ - XmlAttributeAttribute^ myXmlAttributeAttribute = gcnew XmlAttributeAttribute; - myXmlAttributeAttribute->AttributeName = "Name"; - myXmlAttributes->XmlAttribute = myXmlAttributeAttribute; - - // Add to the XmlAttributeOverrides. Specify the member name. - myXmlAttributeOverrides->Add( Student::typeid, "StudentName", myXmlAttributes ); - - // Create the XmlSerializer. - mySerializer = gcnew XmlSerializer( Student::typeid,myXmlAttributeOverrides ); - writer = gcnew StreamWriter( studentFilename ); - - // Create an instance of the class that will be serialized. - Student^ myStudent = gcnew Student; - - // Set the Name property, which will be generated as an XML attribute. - myStudent->StudentName = "James"; - myStudent->StudentNumber = 1; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myStudent ); - writer->Close(); - - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ myXmlBookAttributeOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ myXmlBookAttributes = gcnew XmlAttributes; - - /* Create an XmlAttributeAttribute set it to - the XmlAttribute property of the XmlAttributes object.*/ - XmlAttributeAttribute^ myXmlBookAttributeAttribute = gcnew XmlAttributeAttribute( "Name" ); - myXmlBookAttributes->XmlAttribute = myXmlBookAttributeAttribute; - - // Add to the XmlAttributeOverrides. Specify the member name. - myXmlBookAttributeOverrides->Add( Book::typeid, "BookName", myXmlBookAttributes ); - - // Create the XmlSerializer. - mySerializer = gcnew XmlSerializer( Book::typeid,myXmlBookAttributeOverrides ); - writer = gcnew StreamWriter( bookFilename ); - - // Create an instance of the class that will be serialized. - Book^ myBook = gcnew Book; - - // Set the Name property, which will be generated as an XML attribute. - myBook->BookName = ".NET"; - myBook->BookNumber = 10; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myBook ); - writer->Close(); -} - -int main() -{ - SerializeObject( "Student.xml", "Book.xml" ); -} -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_Constructor/CPP/xmlrootattribute_constructor.cpp b/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_Constructor/CPP/xmlrootattribute_constructor.cpp deleted file mode 100644 index a12e4ff3e02..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_Constructor/CPP/xmlrootattribute_constructor.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// System::Xml::Serialization::XmlRootAttribute.XmlRootAttribute(String*) - -/* The following example demonstrates the constructor -'XmlRootAttribute(String*)' of class 'XmlRootAttribute'. -This program demonstrates 'Student' class to -which the 'XmlRootAttribute(String*)' constructor has been applied. -*/ - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that is the default root element. -public ref class Student -{ -public: - String^ Name; -}; - -public ref class XMLRootAttributeClass -{ -// -public: - void SerializeOrder( String^ filename ) - { - // Create an XmlSerializer instance using the method below. - XmlSerializer^ myXmlSerializer = CreateOverrider(); - - // Create the object, and set its Name property. - Student^ myStudent = gcnew Student; - myStudent->Name = "Student class1"; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - myXmlSerializer->Serialize( writer, myStudent ); - writer->Close(); - } - - // Return an XmlSerializer to the root serialization. - XmlSerializer^ CreateOverrider() - { - // Create an XmlAttributes to the default root element. - XmlAttributes^ myXmlAttributes = gcnew XmlAttributes; - - // Create an XmlRootAttribute overloaded constructer - // and set its namespace. - XmlRootAttribute^ myXmlRootAttribute = - gcnew XmlRootAttribute( "OverriddenRootElementName" ); - myXmlRootAttribute->Namespace = "http://www.microsoft.com"; - - // Set the XmlRoot property to the XmlRoot object. - myXmlAttributes->XmlRoot = myXmlRootAttribute; - XmlAttributeOverrides^ myXmlAttributeOverrides = - gcnew XmlAttributeOverrides; - - // Add the XmlAttributes object to the XmlAttributeOverrides object - myXmlAttributeOverrides->Add( Student::typeid, myXmlAttributes ); - - // Create the Serializer, and return it. - XmlSerializer^ myXmlSerializer = gcnew XmlSerializer( - Student::typeid, myXmlAttributeOverrides ); - return myXmlSerializer; - } -// -}; - -int main() -{ - XMLRootAttributeClass^ myXMLRootAttributeClass = - gcnew XMLRootAttributeClass; - myXMLRootAttributeClass->SerializeOrder( - "XMLRootAttributeConstructor.xml" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp b/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp deleted file mode 100644 index c87e784d7f0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// System::Xml::Serialization::XmlRootAttribute.ElementName - -// The following example demonstrates the property -// 'ElementName' of class 'XmlRootAttribute'. -// This program demonstrates 'Student' class to -// which the 'ElementName' property has been applied. - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that is the default root element. -public ref class Student -{ -public: - String^ Name; -}; - -public ref class XMLRootAttributeClass -{ -// -public: - void SerializeOrder( String^ filename ) - { - // Create an XmlSerializer instance using the method below. - XmlSerializer^ myXmlSerializer = CreateOverrider(); - - // Create the object, and set its Name property. - Student^ myStudent = gcnew Student; - myStudent->Name = "Student class1"; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - myXmlSerializer->Serialize( writer, myStudent ); - writer->Close(); - } - - // Return an XmlSerializer to the root serialization. - XmlSerializer^ CreateOverrider() - { - // Create an XmlAttributes to the default root element. - XmlAttributes^ myXmlAttributes = gcnew XmlAttributes; - - // Create an XmlRootAttribute and set its element name and namespace. - XmlRootAttribute^ myXmlRootAttribute = gcnew XmlRootAttribute; - myXmlRootAttribute->ElementName = "OverriddenRootElementName"; - myXmlRootAttribute->Namespace = "http://www.microsoft.com"; - - // Set the XmlRoot property to the XmlRoot object. - myXmlAttributes->XmlRoot = myXmlRootAttribute; - XmlAttributeOverrides^ myXmlAttributeOverrides = - gcnew XmlAttributeOverrides; - - // Add the XmlAttributes object to the XmlAttributeOverrides object. - myXmlAttributeOverrides->Add( Student::typeid, myXmlAttributes ); - - // Create the Serializer, and return it. - XmlSerializer^ myXmlSerializer = gcnew XmlSerializer( - Student::typeid, myXmlAttributeOverrides ); - return myXmlSerializer; - } -// -}; - -int main() -{ - XMLRootAttributeClass^ myXMLRootAttributeClass = - gcnew XMLRootAttributeClass; - myXMLRootAttributeClass->SerializeOrder( - "XMLRootAttributeConstuctor.xml" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp b/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp deleted file mode 100644 index d2b959c3203..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp +++ /dev/null @@ -1,77 +0,0 @@ - - -// System::Xml::Serialization::XmlTypeAttribute.XmlTypeAttribute() -// System::Xml::Serialization::XmlTypeAttribute.XmlTypeAttribute(String*) -// The following example demonstrates the contructors 'XmlTypeAttribute()' -// and 'XmlTypeAttribute(String*)' of class 'XmlTypeAttribute'. -// This program demonstrates 'Person' and 'Address' classes to -// which the 'XmlTypeAttribute' has been applied. This sample then -// serializes an Object* of class 'Person' into an XML document. -// -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Address -{ -public: - String^ state; - String^ zip; -}; - -public ref class Person -{ -public: - String^ personName; - Address^ address; -}; - -public ref class PersonTypeAttribute -{ -public: - XmlSerializer^ CreateOverrider() - { - XmlAttributeOverrides^ personOverride = gcnew XmlAttributeOverrides; - XmlAttributes^ personAttributes = gcnew XmlAttributes; - XmlTypeAttribute^ personType = gcnew XmlTypeAttribute; - personType->TypeName = "Employee"; - personType->Namespace = "http://www.microsoft.com"; - personAttributes->XmlType = personType; - XmlAttributes^ addressAttributes = gcnew XmlAttributes; - - // Create 'XmlTypeAttribute' with 'TypeName' as an argument. - XmlTypeAttribute^ addressType = gcnew XmlTypeAttribute( "Address" ); - addressType->Namespace = "http://www.microsoft.com"; - addressAttributes->XmlType = addressType; - personOverride->Add( Person::typeid, personAttributes ); - personOverride->Add( Address::typeid, addressAttributes ); - XmlSerializer^ myXmlSerializer = gcnew XmlSerializer( Person::typeid,personOverride ); - return myXmlSerializer; - } - - void SerializeObject( String^ filename ) - { - XmlSerializer^ myXmlSerializer = CreateOverrider(); - Address^ myAddress = gcnew Address; - myAddress->state = "AAA"; - myAddress->zip = "11111"; - Person^ myPerson = gcnew Person; - myPerson->personName = "Smith"; - myPerson->address = myAddress; - - // Serialize to a file. - TextWriter^ writer = gcnew StreamWriter( filename ); - myXmlSerializer->Serialize( writer, myPerson ); - } -}; - -int main() -{ - PersonTypeAttribute^ myPersonTypeAttribute = gcnew PersonTypeAttribute; - myPersonTypeAttribute->SerializeObject( "XmlType.xml" ); -} -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp deleted file mode 100644 index 5c3508dc8e8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; - -public ref class Group -{ -public: - String^ GroupName; - - // The UnknownAttributes array will be used to collect all unknown - // attributes found when deserializing. - - [XmlAnyAttributeAttribute] - array^XAttributes; -}; - -void SerializeObject( String^ filename, Object^ g ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, g ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = safe_cast(ser->Deserialize( fs )); - fs->Close(); - - // Write out the data, including unknown attributes. - Console::WriteLine( g->GroupName ); - Console::WriteLine( "Number of unknown attributes: {0}", g->XAttributes->Length ); - for ( IEnumerator ^ e = g->XAttributes->GetEnumerator(); e->MoveNext(); ) - { - XmlAttribute^ xAtt = safe_cast(e->Current); - Console::WriteLine( "{0}: {1}", xAtt->Name, xAtt->InnerXml ); - } - SerializeObject( "AttributesAdded.xml", g ); -} - -int main() -{ - // Deserialize the file containing unknown attributes. - DeserializeObject( "UnknownAttributes.xml" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp deleted file mode 100644 index 31e83e62519..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -public ref class Group -{ -public: - String^ GroupName; - - // The Things array will be used to collect all unknown - // attributes found when deserializing. - array^Things; -}; - -XmlSerializer^ CreateOverrideSerializer(); -void DeserializeObject( String^ filename ) -{ - // Use the CreateOverrideSerializer to return an instance - // of the XmlSerializer customized for overrides. - XmlSerializer^ ser = CreateOverrideSerializer(); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = safe_cast(ser->Deserialize( fs )); - fs->Close(); - Console::WriteLine( g->GroupName ); - Console::WriteLine( g->Things->Length ); - for ( IEnumerator ^ e = g->Things->GetEnumerator(); e->MoveNext(); ) - { - XmlAttribute^ xAtt = safe_cast(e->Current); - Console::WriteLine( "{0}: {1}", xAtt->Name, xAtt->InnerXml ); - } -} - -XmlSerializer^ CreateOverrideSerializer() -{ - // Override the Things field to capture all - // unknown XML attributes. - XmlAnyAttributeAttribute^ myAnyAttribute = gcnew XmlAnyAttributeAttribute; - XmlAttributeOverrides^ xOverride = gcnew XmlAttributeOverrides; - XmlAttributes^ xAtts = gcnew XmlAttributes; - xAtts->XmlAnyAttribute = myAnyAttribute; - xOverride->Add( Group::typeid, "Things", xAtts ); - return gcnew XmlSerializer( Group::typeid,xOverride ); -} - -int main() -{ - DeserializeObject( "UnknownAttributes.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp deleted file mode 100644 index 9915009fc75..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp +++ /dev/null @@ -1,117 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -using namespace System::Xml::Schema; - -[XmlRoot(Namespace="http://www.cohowinery.com")] -public ref class Group -{ -public: - String^ GroupName; - - // This is for serializing Employee elements. - - [XmlAnyElement(Name="Employee")] - array^UnknownEmployees; - - // This is for serializing City elements. - - [XmlAnyElement - (Name="City", - Namespace="http://www.cpandl.com")] - array^UnknownCity; - - // This one is for all other unknown elements. - - [XmlAnyElement] - array^UnknownElements; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // Create an XmlNamespaces to use. - XmlSerializerNamespaces^ namespaces = gcnew XmlSerializerNamespaces; - namespaces->Add( "c", "http://www.cohowinery.com" ); - namespaces->Add( "i", "http://www.cpandl.com" ); - Group^ myGroup = gcnew Group; - - // Create arrays of arbitrary XmlElement objects. - // First create an XmlDocument, used to create the - // XmlElement objects. - XmlDocument^ xDoc = gcnew XmlDocument; - - // Create an array of Employee XmlElement objects. - XmlElement^ El1 = xDoc->CreateElement( "Employee", "http://www.cohowinery.com" ); - El1->InnerText = "John"; - XmlElement^ El2 = xDoc->CreateElement( "Employee", "http://www.cohowinery.com" ); - El2->InnerText = "Joan"; - XmlElement^ El3 = xDoc->CreateElement( "Employee", "http://www.cohowinery.com" ); - El3->InnerText = "Jim"; - array^employees = {El1,El2,El3}; - myGroup->UnknownEmployees = employees; - - // Create an array of City XmlElement objects. - XmlElement^ inf1 = xDoc->CreateElement( "City", "http://www.cpandl.com" ); - inf1->InnerText = "Tokyo"; - XmlElement^ inf2 = xDoc->CreateElement( "City", "http://www.cpandl.com" ); - inf2->InnerText = "New York"; - XmlElement^ inf3 = xDoc->CreateElement( "City", "http://www.cpandl.com" ); - inf3->InnerText = "Rome"; - array^cities = {inf1,inf2,inf3}; - myGroup->UnknownCity = cities; - XmlElement^ xEl1 = xDoc->CreateElement( "bld" ); - xEl1->InnerText = "42"; - XmlElement^ xEl2 = xDoc->CreateElement( "Region" ); - xEl2->InnerText = "West"; - XmlElement^ xEl3 = xDoc->CreateElement( "type" ); - xEl3->InnerText = "Technical"; - array^elements = {xEl1,xEl2,xEl3}; - myGroup->UnknownElements = elements; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup, namespaces ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup; - myGroup = safe_cast(ser->Deserialize( fs )); - fs->Close(); - for ( int i = 0; i < myGroup->UnknownEmployees->Length; ++i ) - { - XmlElement^ xEmp = myGroup->UnknownEmployees[ i ]; - Console::WriteLine( "{0}: {1}", xEmp->LocalName, xEmp->InnerText ); - } - for ( int i = 0; i < myGroup->UnknownCity->Length; ++i ) - { - XmlElement^ xCity = myGroup->UnknownCity[ i ]; - Console::WriteLine( "{0}: {1}", xCity->LocalName, xCity->InnerText ); - } - for ( int i = 0; i < myGroup->UnknownElements->Length; ++i ) - { - XmlElement^ xEmp = myGroup->UnknownElements[ i ]; - Console::WriteLine( "{0}: {1}", xEmp->LocalName, xEmp->InnerText ); - } -} - -int main() -{ - SerializeObject( "AnyElementArray.xml" ); - DeserializeObject( "AnyElementArray.xml" ); - Console::WriteLine( "Done" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp deleted file mode 100644 index 9787259757c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp +++ /dev/null @@ -1,107 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; -using namespace System::Xml::Schema; -public ref class Item -{ -public: - String^ ItemID; - Item(){} - - Item( String^ id ) - { - ItemID = id; - } -}; - -public ref class NewItem: public Item -{ -public: - String^ Category; - NewItem(){} - - NewItem( String^ id, String^ cat ) - { - ItemID = id; - Category = cat; - } -}; - -public ref class PurchaseOrder -{ -public: - - [XmlArrayItem(DataType="gMonth", - ElementName="MyMonths", - Namespace="http://www.cohowinery.com")] - array^Months; - - [XmlArrayItem(Item::typeid),XmlArrayItem(NewItem::typeid)] - array^Items; - - [XmlArray(IsNullable=true)] - [XmlArrayItem(String::typeid), - XmlArrayItem(Double::typeid), - XmlArrayItem(NewItem::typeid)] - array^Things; -}; - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class; - // specify the type of object to serialize. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create a PurchaseOrder and set its properties. - PurchaseOrder^ po = gcnew PurchaseOrder; - array^months = {"March","May","August"}; - po->Months = months; - array^items = {gcnew Item( "a1" ),gcnew NewItem( "b1","book" )}; - po->Items = items; - array^things = {"String",2003.31,gcnew NewItem( "Item100","book" )}; - po->Things = things; - - // Serialize the purchase order, and close the TextWriter. - serializer->Serialize( writer, po ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class; - // specify the type of object to be deserialized. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - PurchaseOrder^ po; - - /* Use the Deserialize method to restore the object's state with - data from the XML document. */ - po = safe_cast(serializer->Deserialize( fs )); - for ( int i = 0; i < po->Months->Length; ++i ) - Console::WriteLine( po->Months[ i ] ); - for ( int i = 0; i < po->Items->Length; ++i ) - Console::WriteLine( po->Items[ i ]->ItemID ); - for ( int i = 0; i < po->Things->Length; ++i ) - Console::WriteLine( po->Things[ i ] ); -} - -int main() -{ - // Read and write purchase orders. - SerializeObject( "ArrayItemEx.xml" ); - DeserializeObject( "ArrayItemEx.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp deleted file mode 100644 index 37278b0a8b3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -public ref class Group -{ -public: - String^ GroupName; - - [XmlAnyElement] - array^Things; -}; - -void SerializeObject( String^ filename ); -void DeserializeObject( String^ filename ); -XmlSerializer^ CreateOverrideSerializer(); -int main() -{ - // 1 Run this and create the XML document. - // 2 Add new elements to the XML document. - // 3 Comment out the next line, and uncomment - // the DeserializeObject line to deserialize the - // XML document and see unknown elements. - SerializeObject( "UnknownElements.xml" ); - - // DeserializeObject(S"UnknownElements.xml"); -} - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - Group^ g = gcnew Group; - g->GroupName = "MyGroup"; - ser->Serialize( writer, g ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = CreateOverrideSerializer(); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = safe_cast(ser->Deserialize( fs )); - fs->Close(); - Console::WriteLine( g->GroupName ); - Console::WriteLine( g->Things->Length ); - for ( int i = 0; i < g->Things->Length; ++i ) - { - XmlElement^ xelement = safe_cast(g->Things[ i ]); - Console::WriteLine( "{0}: {1}", xelement->Name, xelement->InnerXml ); - } -} - -XmlSerializer^ CreateOverrideSerializer() -{ - XmlAnyElementAttribute^ myAnyElement = gcnew XmlAnyElementAttribute; - XmlAttributeOverrides^ xOverride = gcnew XmlAttributeOverrides; - XmlAttributes^ xAtts = gcnew XmlAttributes; - xAtts->XmlAnyElements->Add( myAnyElement ); - xOverride->Add( Group::typeid, "Things", xAtts ); - return gcnew XmlSerializer( Group::typeid,xOverride ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp deleted file mode 100644 index a86b3632f06..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp +++ /dev/null @@ -1,86 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Student -{ -public: - - [XmlAttributeAttribute] - String^ Name; - - [XmlNamespaceDeclarationsAttribute] - XmlSerializerNamespaces^ myNamespaces; -}; - -void SerializeStudent( String^ filename ); -void DeserializeStudent( String^ filename ); -int main() -{ - SerializeStudent( "Student.xml" ); - DeserializeStudent( "Student.xml" ); -} - -void SerializeStudent( String^ filename ) -{ - XmlAttributes^ atts = gcnew XmlAttributes; - - // Set to true to preserve namespaces, - // or false to ignore them. - atts->Xmlns = true; - XmlAttributeOverrides^ xover = gcnew XmlAttributeOverrides; - - // Add the XmlAttributes and specify the name of the element - // containing namespaces. - xover->Add( Student::typeid, "myNamespaces", atts ); - - // Create the XmlSerializer using the - // XmlAttributeOverrides object. - XmlSerializer^ xser = gcnew XmlSerializer( Student::typeid,xover ); - Student^ myStudent = gcnew Student; - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - ns->Add( "myns1", "http://www.cpandl.com" ); - ns->Add( "myns2", "http://www.cohowinery.com" ); - myStudent->myNamespaces = ns; - myStudent->Name = "Student1"; - FileStream^ fs = gcnew FileStream( filename,FileMode::Create ); - xser->Serialize( fs, myStudent ); - fs->Close(); -} - -void DeserializeStudent( String^ filename ) -{ - XmlAttributes^ atts = gcnew XmlAttributes; - - // Set to true to preserve namespaces, or false to ignore them. - atts->Xmlns = true; - XmlAttributeOverrides^ xover = gcnew XmlAttributeOverrides; - - // Add the XmlAttributes and specify the name of the - // element containing namespaces. - xover->Add( Student::typeid, "myNamespaces", atts ); - - // Create the XmlSerializer using the - // XmlAttributeOverrides object. - XmlSerializer^ xser = gcnew XmlSerializer( Student::typeid,xover ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Student^ myStudent; - myStudent = safe_cast(xser->Deserialize( fs )); - fs->Close(); - - // Use the ToArray method to get an array of - // XmlQualifiedName objects. - array^qNames = myStudent->myNamespaces->ToArray(); - for ( int i = 0; i < qNames->Length; i++ ) - { - Console::WriteLine( "{0}:{1}", qNames[ i ]->Name, qNames[ i ]->Namespace ); - - } -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp deleted file mode 100644 index 51329745b7a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp +++ /dev/null @@ -1,131 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; - -[XmlType(IncludeInSchema=false)] - -public enum class ItemChoiceType -{ - None, Word, Number, DecimalNumber -}; - -public enum class MoreChoices -{ - None, Item, Amount, Temp -}; - -public ref class Choices -{ -public: - - // The MyChoice field can be set to any one of - // the types below. - - [XmlChoiceIdentifier("EnumType")] - [XmlElement("Word",String::typeid)] - [XmlElement("Number",Int32::typeid)] - [XmlElement("DecimalNumber",Double::typeid)] - Object^ MyChoice; - - // Don't serialize this field. The EnumType field - // contains the enumeration value that corresponds - // to the MyChoice field value. - - [XmlIgnore] - ItemChoiceType EnumType; - - // The ManyChoices field can contain an array - // of choices. Each choice must be matched to - // an array item in the ChoiceArray field. - - [XmlChoiceIdentifier("ChoiceArray")] - [XmlElement("Item",String::typeid)] - [XmlElement("Amount",Int32::typeid)] - [XmlElement("Temp",Double::typeid)] - array^ManyChoices; - - // TheChoiceArray field contains the enumeration - // values, one for each item in the ManyChoices array. - - [XmlIgnore] - array^ChoiceArray; -}; - -void SerializeObject( String^ filename ); -void DeserializeObject( String^ filename ); -int main() -{ - SerializeObject( "Choices.xml" ); - DeserializeObject( "Choices.xml" ); -} - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = gcnew XmlSerializer( Choices::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - Choices^ myChoices = gcnew Choices; - - // Set the MyChoice field to a string. Set the - // EnumType to Word. - myChoices->MyChoice = "Book"; - myChoices->EnumType = ItemChoiceType::Word; - - // Populate an object array with three items, one - // of each enumeration type. Set the array to the - // ManyChoices field. - array^strChoices = {"Food",5,98.6}; - myChoices->ManyChoices = strChoices; - - // For each item in the ManyChoices array, add an - // enumeration value. - array^ itmChoices = {MoreChoices::Item,MoreChoices::Amount,MoreChoices::Temp}; - myChoices->ChoiceArray = itmChoices; - mySerializer->Serialize( writer, myChoices ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Choices::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Choices^ myChoices = safe_cast(ser->Deserialize( fs )); - fs->Close(); - - // Disambiguate the MyChoice value using the enumeration. - if ( myChoices->EnumType == ItemChoiceType::Word ) - { - Console::WriteLine( "Word: {0}", myChoices->MyChoice->ToString() ); - } - else - if ( myChoices->EnumType == ItemChoiceType::Number ) - { - Console::WriteLine( "Number: {0}", myChoices->MyChoice->ToString() ); - } - else - if ( myChoices->EnumType == ItemChoiceType::DecimalNumber ) - { - Console::WriteLine( "DecimalNumber: {0}", myChoices->MyChoice->ToString() ); - } - - // Disambiguate the ManyChoices values using the enumerations. - for ( int i = 0; i < myChoices->ManyChoices->Length; i++ ) - { - if ( myChoices->ChoiceArray[ i ] == MoreChoices::Item ) - Console::WriteLine( "Item: {0}", myChoices->ManyChoices[ i ] ); - else - if ( myChoices->ChoiceArray[ i ] == MoreChoices::Amount ) - Console::WriteLine( "Amount: ", myChoices->ManyChoices[ i ]->ToString() ); - if ( myChoices->ChoiceArray[ i ] == MoreChoices::Temp ) - Console::WriteLine( "Temp: {0}", myChoices->ManyChoices[ i ]->ToString() ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp deleted file mode 100644 index 61dea2ac426..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; -public ref class Person: public IXmlSerializable -{ -private: - - // Private state - String^ personName; - -public: - - // Constructors - Person( String^ name ) - { - personName = name; - } - - Person() - { - personName = nullptr; - } - - // Xml Serialization Infrastructure - // - virtual void WriteXml( XmlWriter^ writer ) - { - writer->WriteString( personName ); - } - // - - // - virtual void ReadXml( XmlReader^ reader ) - { - personName = reader->ReadString(); - } - // - - // - virtual XmlSchema^ GetSchema() - { - return nullptr; - } - // - - // Print - virtual String^ ToString() override - { - return (personName); - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp deleted file mode 100644 index f5ab5ef1cb0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -int main() -{ - XmlSerializer^ serializer = gcnew XmlSerializer( Person::typeid ); - FileStream^ file = gcnew FileStream( "test.xml",FileMode::Open ); - Person^ aPerson = dynamic_cast(serializer->Deserialize( file )); - Console::WriteLine( aPerson ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp deleted file mode 100644 index 35d2a29a532..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -int main() -{ - // Create a person object. - Person ^ fred = gcnew Person( "Fred Flintstone" ); - - // Serialize the object to a file. - XmlTextWriter^ writer = gcnew XmlTextWriter( "test.xml", nullptr ); - XmlSerializer^ serializer = gcnew XmlSerializer( Person::typeid ); - serializer->Serialize( writer, fred ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp deleted file mode 100644 index 22cef24ad7a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - String^ GroupName; -}; - -public ref class Test -{ -private: - void Serializer_UnknownElement( Object^ sender, XmlElementEventArgs^ e ) - { - Console::WriteLine( "Unknown Element" ); - Console::Write( "\t {0}", e->Element->Name ); - Console::WriteLine( " {0}", e->Element->InnerXml ); - Console::WriteLine( "\t LineNumber: {0}", e->LineNumber ); - Console::WriteLine( "\t LinePosition: {0}", e->LinePosition ); - Group^ x = dynamic_cast(e->ObjectBeingDeserialized); - Console::WriteLine( x->GroupName ); - Console::WriteLine( sender ); - } - -public: - void DeserializeObject( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // Add a delegate to handle unknown element events. - ser->UnknownElement += gcnew XmlElementEventHandler( this, &Test::Serializer_UnknownElement ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = dynamic_cast(ser->Deserialize( fs )); - fs->Close(); - } -}; - -int main() -{ - Test^ t = gcnew Test; - - // Deserialize the file containing unknown elements. - t->DeserializeObject( "UnknownElements.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp deleted file mode 100644 index e453759982a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// System::Xml::Serialization::XmlSerializerNamespaces.constructor - -// The following example demonstrates the constructor of class -// XmlSerializerNamespaces. This sample serializes an Object* of 'MyPriceClass' -// into an XML document. - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; - -public ref class MyPriceClass -{ -public: - [XmlAttributeAttribute] - String^ Units; - Decimal Price; -}; - -public ref class MyBook -{ -public: - String^ BookName; - String^ Author; - MyPriceClass^ BookPrice; - String^ Description; -}; - -public ref class MyMainClass -{ -// -public: - void CreateBook( String^ filename ) - { - try - { - // Create instance of XmlSerializerNamespaces and add the namespaces. - XmlSerializerNamespaces^ myNameSpaces = gcnew XmlSerializerNamespaces; - myNameSpaces->Add( "BookName", "http://www.cpandl.com" ); - - // Create instance of XmlSerializer and specify the type of object - // to be serialized. - XmlSerializer^ mySerializerObject = - gcnew XmlSerializer( MyBook::typeid ); - - TextWriter^ myWriter = gcnew StreamWriter( filename ); - // Create object to be serialized. - MyBook^ myXMLBook = gcnew MyBook; - - myXMLBook->Author = "XMLAuthor"; - myXMLBook->BookName = "DIG THE XML"; - myXMLBook->Description = "This is a XML Book"; - - MyPriceClass^ myBookPrice = gcnew MyPriceClass; - myBookPrice->Price = (Decimal)45.89; - myBookPrice->Units = "$"; - myXMLBook->BookPrice = myBookPrice; - - // Serialize the object. - mySerializerObject->Serialize( myWriter, myXMLBook, myNameSpaces ); - myWriter->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0} occurred", e->Message ); - } - } -// -}; - -int main() -{ - MyMainClass^ myMain = gcnew MyMainClass; - // Create the XML document. - myMain->CreateBook( "myBook.xml" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp deleted file mode 100644 index 8f321e5bf24..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Text; - -public ref class Thing -{ -public: - String^ ThingName; -}; - -[SoapType("TheGroup","http://www.cohowinery.com")] -public ref class Group -{ -public: - String^ GroupName; - array^Things; - - [SoapElement(DataType="language")] - static String^ Lang = "en"; - - [SoapElement(DataType="integer")] - String^ MyNumber; - - [SoapElement(DataType="duration")] - static String^ ReDate = "8/31/01"; -}; - -void GetMap( String^ filename ) -{ - // Create an XmlSerializer instance. - SoapReflectionImporter^ sri = gcnew SoapReflectionImporter; - XmlTypeMapping^ map = sri->ImportTypeMapping( Group::typeid ); - Console::WriteLine( "ElementName: {0}", map->ElementName ); - Console::WriteLine( "Namespace: {0}", map->Namespace ); - Console::WriteLine( "TypeFullName: {0}", map->TypeFullName ); - Console::WriteLine( "TypeName: {0}", map->TypeName ); - XmlSerializer^ ser = gcnew XmlSerializer( map ); - Group^ xGroup = gcnew Group; - xGroup->GroupName = "MyCar"; - xGroup->MyNumber = "5454"; - xGroup->Things = gcnew array(2); // {new Thing(), new Thing()}; - xGroup->Things[ 0 ] = gcnew Thing; - xGroup->Things[ 1 ] = gcnew Thing; - - // To write the outer wrapper, use an XmlTextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - ser->Serialize( writer, xGroup ); - writer->WriteEndElement(); - writer->Close(); -} - -int main() -{ - GetMap( "MyMap.xml" ); -} -// diff --git a/xml/System.Text.RegularExpressions/Match.xml b/xml/System.Text.RegularExpressions/Match.xml index fcbd7c7c70f..5b96a920302 100644 --- a/xml/System.Text.RegularExpressions/Match.xml +++ b/xml/System.Text.RegularExpressions/Match.xml @@ -227,7 +227,6 @@ The following examples use the regular expression `Console\.Write(Line)?`. The r ## Examples The following example attempts to match a regular expression pattern against a sample string. The example uses the property to store information that is retrieved by the match for display to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Groups/snippet8.cs" interactive="try-dotnet" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/regex match, nextmatch, groups, captures/vb/snippet8.vb" id="Snippet8"::: @@ -294,7 +293,6 @@ The following examples use the regular expression `Console\.Write(Line)?`. The r ## Examples The following example uses the method to capture regular expression matches beyond the first match. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Groups/snippet8.cs" interactive="try-dotnet" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/regex match, nextmatch, groups, captures/vb/snippet8.vb" id="Snippet8"::: diff --git a/xml/System.Text.RegularExpressions/MatchCollection.xml b/xml/System.Text.RegularExpressions/MatchCollection.xml index 3ee8714070c..30727b99502 100644 --- a/xml/System.Text.RegularExpressions/MatchCollection.xml +++ b/xml/System.Text.RegularExpressions/MatchCollection.xml @@ -124,7 +124,6 @@ ## Examples The following example illustrates the use of the class to interrogate a set of instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/MatchCollection/Overview/words.cs" interactive="try-dotnet" id="Snippet0"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Regex_Words/VB/words.vb" id="Snippet0"::: diff --git a/xml/System.Text.RegularExpressions/MatchEvaluator.xml b/xml/System.Text.RegularExpressions/MatchEvaluator.xml index fe842edbf9d..e26b38fa2f5 100644 --- a/xml/System.Text.RegularExpressions/MatchEvaluator.xml +++ b/xml/System.Text.RegularExpressions/MatchEvaluator.xml @@ -63,20 +63,19 @@ Represents the method that is called each time a regular expression match is found during a method operation. A string returned by the method that is represented by the delegate. - delegate method to perform a custom verification or manipulation operation for each match found by a replacement method such as . For each matched string, the method calls the delegate method with a object that represents the match. The delegate method performs whatever processing you prefer and returns a string that the method substitutes for the matched string. + + + +## Examples + The following code example uses the delegate to replace every matched group of characters with the number of the match occurrence. -## Remarks - You can use a delegate method to perform a custom verification or manipulation operation for each match found by a replacement method such as . For each matched string, the method calls the delegate method with a object that represents the match. The delegate method performs whatever processing you prefer and returns a string that the method substitutes for the matched string. - - - -## Examples - The following code example uses the delegate to replace every matched group of characters with the number of the match occurrence. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.text.regularexpressions.MatchEvaluator/CPP/regexreplace.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/MatchEvaluator/Overview/regexreplace.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.MatchEvaluator/VB/regexreplace.vb" id="Snippet1"::: - + ]]> diff --git a/xml/System.Text.RegularExpressions/Regex.xml b/xml/System.Text.RegularExpressions/Regex.xml index 1144af68573..917aec0f9af 100644 --- a/xml/System.Text.RegularExpressions/Regex.xml +++ b/xml/System.Text.RegularExpressions/Regex.xml @@ -3746,7 +3746,6 @@ For more details about `startat`, see the Remarks section of to encode Unicode characters outside of the ASCII range. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding Example/CPP/snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/Overview/snippet.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding Example/VB/snippet.vb" id="Snippet1"::: @@ -145,7 +144,6 @@ ## Examples The following example demonstrates how to create a new instance and display the name of the encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.ctor Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/.ctor/ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.ctor Example/VB/ctor.vb" id="Snippet1"::: @@ -268,7 +266,6 @@ ## Examples The following example demonstrates how to use the method to return the number of bytes required to encode a string using . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount2 Example/CPP/getbytecount-string.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetByteCount/getbytecount-string.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount2 Example/VB/getbytecount-string.vb" id="Snippet1"::: @@ -436,7 +433,6 @@ ## Examples The following example demonstrates how to use the method to return the number of bytes required to encode an array of Unicode characters using . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount1 Example/CPP/getbytecount-char[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetByteCount/getbytecount-char[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount1 Example/VB/getbytecount-char[]-int32-int32.vb" id="Snippet1"::: @@ -700,7 +696,6 @@ ## Examples The following example demonstrates how to use the method to encode a range of characters from a string and store the encoded characters in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes1 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetBytes/getbytes-string-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes1 Example/VB/getbytes-string-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -807,7 +802,6 @@ ## Examples The following example demonstrates how to use the method to encode a range of elements from a Unicode character array and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes2/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes2/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1040,7 +1034,6 @@ ## Examples The following example demonstrates how to use the method to return the number of characters produced by decoding a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetCharCount/getcharcount-byte[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: @@ -1305,7 +1298,6 @@ ## Examples The following example demonstrates how to decode a range of elements from a byte array and store the result in a set of elements in a Unicode character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetChars/getchars-byte[]-int32-int32-char[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: @@ -1524,7 +1516,6 @@ ## Examples The following example demonstrates how to use the method to calculate the bytes required to encode a specified number of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetMaxByteCount/getmaxbytecount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxByteCount Example/VB/getmaxbytecount-int32.vb" id="Snippet1"::: @@ -1602,7 +1593,6 @@ ## Examples The following example demonstrates how to use the method to calculate the maximum number of characters needed to decode a specified number of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetMaxCharCount/getmaxcharcount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxCharCount Example/VB/getmaxcharcount-int32.vb" id="Snippet1"::: @@ -1718,7 +1708,6 @@ ## Examples The following example demonstrates how to use the method to convert a byte array into a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetString1 Example/CPP/getstring-byte[].cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetString/getstring-byte[].cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetString1 Example/VB/getstring-byte[].vb" id="Snippet1"::: diff --git a/xml/System.Text/Decoder.xml b/xml/System.Text/Decoder.xml index d869e58dd73..720bd3c84ca 100644 --- a/xml/System.Text/Decoder.xml +++ b/xml/System.Text/Decoder.xml @@ -83,7 +83,6 @@ The method determines how many charac to convert two different byte arrays into a character array. One of the character's bytes spans the arrays. This is similar to what a object does internally when reading a stream. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Decoder/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Decoder Example/VB/source.vb" id="Snippet1"::: ]]> @@ -147,7 +146,6 @@ The following example demonstrates the use of a to co ## Examples The following example demonstrates two techniques for initializing a new instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.ctor Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Decoder/.ctor/ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Decoder.ctor Example/VB/ctor.vb" id="Snippet1"::: @@ -809,7 +807,6 @@ The following example uses the method to c ## Examples The following code example demonstrates how to use the method to calculate the number of characters required to decode the specified range of bytes in the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Decoder/GetCharCount/getcharcount-byte[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Decoder.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: @@ -1161,7 +1158,6 @@ The following example uses the method to c ## Examples The following example demonstrates how to decode a range of elements from a byte array and store them in a Unicode character array. The method is used to calculate the number of characters needed to store the decoded elements in the array `bytes`. The method decodes the specified elements in the byte array and stores them in the new character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Decoder/GetChars/getchars-byte[]-int32-int32-char[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Decoder.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: diff --git a/xml/System.Text/DecoderExceptionFallback.xml b/xml/System.Text/DecoderExceptionFallback.xml index 906c98ef131..e097ca870a0 100644 --- a/xml/System.Text/DecoderExceptionFallback.xml +++ b/xml/System.Text/DecoderExceptionFallback.xml @@ -63,26 +63,25 @@ Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that cannot be converted to an input character. The fallback throws an exception instead of decoding the input byte sequence. This class cannot be inherited. - class. Specifically, the encoding type's `GetBytes` method encodes a character to a byte sequence, and the `GetChars` method decodes a byte sequence to a character. + + A decoding operation can fail if the input byte sequence cannot be mapped by the encoding. For example, an object cannot decode a byte sequence that yields a character having a code point value that is outside the range U+0000 to U+007F. + + In cases where an encoding or decoding conversion cannot be performed, the .NET Framework provides a failure-handling mechanism called a fallback. Your application can use the predefined .NET Framework decoder fallback, or it can create a custom decoder fallback derived from the and classes. + + The .NET Framework provides two predefined classes that implement different fallback strategies for handling decoding conversion failures. The class substitutes a string provided in place of any input byte sequence that cannot be converted. After the substitute string is emitted, the decoding operation continues converting the remainder of the input. In contrast, the class throws a when an invalid byte sequence is encountered. + + + +## Examples + The following code example demonstrates the and classes. -## Remarks - An encoding maps a Unicode character to an encoded sequence of bytes, which can subsequently be transferred to a physical medium, such as a disk, or over a communications link. Characters can be mapped in various ways, and a particular encoding is represented by a type derived from the class. Specifically, the encoding type's `GetBytes` method encodes a character to a byte sequence, and the `GetChars` method decodes a byte sequence to a character. - - A decoding operation can fail if the input byte sequence cannot be mapped by the encoding. For example, an object cannot decode a byte sequence that yields a character having a code point value that is outside the range U+0000 to U+007F. - - In cases where an encoding or decoding conversion cannot be performed, the .NET Framework provides a failure-handling mechanism called a fallback. Your application can use the predefined .NET Framework decoder fallback, or it can create a custom decoder fallback derived from the and classes. - - The .NET Framework provides two predefined classes that implement different fallback strategies for handling decoding conversion failures. The class substitutes a string provided in place of any input byte sequence that cannot be converted. After the substitute string is emitted, the decoding operation continues converting the remainder of the input. In contrast, the class throws a when an invalid byte sequence is encountered. - - - -## Examples - The following code example demonstrates the and classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/DecoderExceptionFallback/Overview/fallDecExc.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecExc/vb/fallDecExc.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecExc/vb/fallDecExc.vb" id="Snippet1"::: + ]]> Understanding Encodings @@ -171,11 +170,11 @@ Returns a decoder fallback buffer that throws an exception if it cannot convert a sequence of bytes to a character. A decoder fallback buffer that throws an exception when it cannot decode a byte sequence. - class, which is a subclass of the class. A object throws an exception whenever a sequence of bytes is passed to its method. - + class, which is a subclass of the class. A object throws an exception whenever a sequence of bytes is passed to its method. + ]]> @@ -280,11 +279,11 @@ Retrieves the hash code for this instance. The return value is always the same arbitrary value, and has no special significance. - method always returns the same value, the application should not use this value to distinguish one object from another. - + method always returns the same value, the application should not use this value to distinguish one object from another. + ]]> diff --git a/xml/System.Text/DecoderFallbackException.xml b/xml/System.Text/DecoderFallbackException.xml index ae7f270d243..5803a895783 100644 --- a/xml/System.Text/DecoderFallbackException.xml +++ b/xml/System.Text/DecoderFallbackException.xml @@ -69,15 +69,14 @@ The exception that is thrown when a decoder fallback operation fails. This class cannot be inherited. - and classes. -## Examples - The following code example demonstrates the and classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/DecoderExceptionFallback/Overview/fallDecExc.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecExc/vb/fallDecExc.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecExc/vb/fallDecExc.vb" id="Snippet1"::: + ]]> @@ -133,11 +132,11 @@ Initializes a new instance of the class. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -186,11 +185,11 @@ An error message. Initializes a new instance of the class. A parameter specifies the error message. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -241,11 +240,11 @@ The exception that caused this exception. Initializes a new instance of the class. Parameters specify the error message and the inner exception that is the cause of this exception. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -298,11 +297,11 @@ The index position in of the byte that cannot be decoded. Initializes a new instance of the class. Parameters specify the error message, the array of bytes being decoded, and the index of the byte that cannot be decoded. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -351,11 +350,11 @@ Gets the input byte sequence that caused the exception. The input byte array that cannot be decoded. - property to get the position in the input byte array of the byte that cannot be decoded. - + property to get the position in the input byte array of the byte that cannot be decoded. + ]]> @@ -403,11 +402,11 @@ Gets the index position in the input byte sequence of the byte that caused the exception. The index position in the input byte array of the byte that cannot be decoded. The index position is zero-based. - property to retrieve the input byte array that contains the byte that cannot be decoded. - + property to retrieve the input byte array that contains the byte that cannot be decoded. + ]]> diff --git a/xml/System.Text/DecoderReplacementFallback.xml b/xml/System.Text/DecoderReplacementFallback.xml index 818918b7106..3ed787d0087 100644 --- a/xml/System.Text/DecoderReplacementFallback.xml +++ b/xml/System.Text/DecoderReplacementFallback.xml @@ -67,28 +67,27 @@ Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that cannot be converted to an output character. The fallback emits a user-specified replacement string instead of a decoded input byte sequence. This class cannot be inherited. - object cannot decode a byte value greater than 0x7F. If an input byte sequence cannot be converted to an output character, a object emits a replacement string into the output to represent the original input byte sequence. The conversion process then continues to decode the remainder of the original input. + + The replacement string used by a object is determined by the call to its class constructor. Two options are available: + +- Replacement with the default character. If you call the constructor, the replacement character is "?" (U+003F). + +- Replacement with a string of your choice. If you call the constructor, you provide the replacement string. + + This class is one of two .NET Framework classes that implement different fallback strategies for handling decoding conversion failures. The other class is the class, which throws a when an invalid byte sequence is encountered. + + + +## Examples + The following code example demonstrates the class. -## Remarks - A common reason for an encoding or decoding operation to fail is if the underlying encoding class does not provide a mapping between a character and an equivalent byte sequence. For example, an object cannot decode a byte value greater than 0x7F. If an input byte sequence cannot be converted to an output character, a object emits a replacement string into the output to represent the original input byte sequence. The conversion process then continues to decode the remainder of the original input. - - The replacement string used by a object is determined by the call to its class constructor. Two options are available: - -- Replacement with the default character. If you call the constructor, the replacement character is "?" (U+003F). - -- Replacement with a string of your choice. If you call the constructor, you provide the replacement string. - - This class is one of two .NET Framework classes that implement different fallback strategies for handling decoding conversion failures. The other class is the class, which throws a when an invalid byte sequence is encountered. - - - -## Examples - The following code example demonstrates the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/DecoderReplacementFallback/Overview/fallDecRpl.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecRpl/vb/fallDecRpl.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecRpl/vb/fallDecRpl.vb" id="Snippet1"::: + ]]> @@ -144,11 +143,11 @@ Initializes a new instance of the class. - object is "?". - + object is "?". + ]]> @@ -195,11 +194,11 @@ A string that is emitted in a decoding operation in place of an input byte sequence that cannot be decoded. Initializes a new instance of the class using a specified replacement string. - object. A commonly used value is the Unicode "Replacement Character" (U+FFFD), which is specifically intended to replace an incoming character having a value that is unknown or unrepresentable in Unicode. - + object. A commonly used value is the Unicode "Replacement Character" (U+FFFD), which is specifically intended to replace an incoming character having a value that is unknown or unrepresentable in Unicode. + ]]> @@ -400,11 +399,11 @@ Retrieves the hash code for the value of the object. The hash code of the value of the object. - object is the value of its property. - + object is the value of its property. + ]]> diff --git a/xml/System.Text/Encoder.xml b/xml/System.Text/Encoder.xml index 44b03ef06e8..3b1b3d9c2e4 100644 --- a/xml/System.Text/Encoder.xml +++ b/xml/System.Text/Encoder.xml @@ -85,7 +85,6 @@ A object maintains state information between successi . Next, the array of characters is encoded using an . -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoder/Overview/snippet.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder Example/VB/snippet.vb" id="Snippet1"::: ]]> @@ -148,7 +147,6 @@ The following example demonstrates how to convert an array of Unicode characters ## Examples The following example demonstrates two techniques for initializing a new instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.ctor Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoder/.ctor/ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder.ctor Example/VB/ctor.vb" id="Snippet1"::: @@ -779,7 +777,6 @@ The following example demonstrates how to convert an array of Unicode characters The following code example demonstrates how to use the method to return the number of bytes required to encode an array of characters using a Unicode . -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoder/GetByteCount/getbytecount-char[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder.GetByteCount Example/VB/getbytecount-char[]-int32-int32.vb" id="Snippet1"::: @@ -1024,7 +1021,6 @@ If your application is to convert many segments of an input stream, consider usi ## Examples The following example demonstrates how to encode a range of elements from a character array and store the encoded bytes in a range of elements in a byte array. The method is used to determine the size of the array required by . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoder/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder.GetBytes Example/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: diff --git a/xml/System.Text/EncoderExceptionFallback.xml b/xml/System.Text/EncoderExceptionFallback.xml index f81fb780759..cdb0158d924 100644 --- a/xml/System.Text/EncoderExceptionFallback.xml +++ b/xml/System.Text/EncoderExceptionFallback.xml @@ -63,26 +63,25 @@ Provides a failure-handling mechanism, called a fallback, for an input character that cannot be converted to an output byte sequence. The fallback throws an exception if an input character cannot be converted to an output byte sequence. This class cannot be inherited. - class. Specifically, the encoding type's `GetBytes` method encodes a character to a byte sequence, and the `GetChars` method decodes a byte sequence to a character. + + An encoding operation can fail if the input character cannot be represented by the encoding. For example, a object cannot encode a character that yields a Unicode code point value that is outside the range U+0000 to U+007F. + + In cases where an encoding or decoding conversion cannot be performed, the .NET Framework provides a failure-handling mechanism called a fallback. Your application can use the predefined .NET Framework encoder fallback, or it can create a custom encoder fallback derived from the and classes. + + The .NET Framework provides two predefined classes that implement different fallback strategies for handling encoding conversion failures. The class substitutes a string provided for any input character that cannot be converted. The substitute string is encoded in place of the invalid character, and then the encoding operation continues converting the remainder of the input. In contrast, the class throws a when an invalid character is encountered. + + + +## Examples + The following code example demonstrates the and classes. -## Remarks - An encoding maps a Unicode character to an encoded sequence of bytes, which can subsequently be transferred to a physical medium, such as a disk, or over a communications link. Characters can be mapped in various ways, and a particular encoding is represented by a type derived from the class. Specifically, the encoding type's `GetBytes` method encodes a character to a byte sequence, and the `GetChars` method decodes a byte sequence to a character. - - An encoding operation can fail if the input character cannot be represented by the encoding. For example, a object cannot encode a character that yields a Unicode code point value that is outside the range U+0000 to U+007F. - - In cases where an encoding or decoding conversion cannot be performed, the .NET Framework provides a failure-handling mechanism called a fallback. Your application can use the predefined .NET Framework encoder fallback, or it can create a custom encoder fallback derived from the and classes. - - The .NET Framework provides two predefined classes that implement different fallback strategies for handling encoding conversion failures. The class substitutes a string provided for any input character that cannot be converted. The substitute string is encoded in place of the invalid character, and then the encoding operation continues converting the remainder of the input. In contrast, the class throws a when an invalid character is encountered. - - - -## Examples - The following code example demonstrates the and classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncoderExceptionFallback/Overview/fallEncExc.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncExc/vb/fallEncExc.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncExc/vb/fallEncExc.vb" id="Snippet1"::: + ]]> Understanding Encodings @@ -171,11 +170,11 @@ Returns an encoder fallback buffer that throws an exception if it cannot convert a character sequence to a byte sequence. An encoder fallback buffer that throws an exception when it cannot encode a character sequence. - class, which is a subclass of the class. An object throws an exception whenever characters are passed to its method. - + class, which is a subclass of the class. An object throws an exception whenever characters are passed to its method. + ]]> @@ -280,11 +279,11 @@ Retrieves the hash code for this instance. The return value is always the same arbitrary value, and has no special significance. - method always returns the same value, the application should not use this value to distinguish one instance of the class from another. - + method always returns the same value, the application should not use this value to distinguish one instance of the class from another. + ]]> diff --git a/xml/System.Text/EncoderFallbackException.xml b/xml/System.Text/EncoderFallbackException.xml index 334e1c213a3..93dd2de32ee 100644 --- a/xml/System.Text/EncoderFallbackException.xml +++ b/xml/System.Text/EncoderFallbackException.xml @@ -69,15 +69,14 @@ The exception that is thrown when an encoder fallback operation fails. This class cannot be inherited. - and classes. -## Examples - The following code example demonstrates the and classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncoderExceptionFallback/Overview/fallEncExc.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncExc/vb/fallEncExc.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncExc/vb/fallEncExc.vb" id="Snippet1"::: + ]]> @@ -133,11 +132,11 @@ Initializes a new instance of the class. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -186,11 +185,11 @@ An error message. Initializes a new instance of the class. A parameter specifies the error message. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -241,11 +240,11 @@ The exception that caused this exception. Initializes a new instance of the class. Parameters specify the error message and the inner exception that is the cause of this exception. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -428,11 +427,11 @@ Gets the index position in the input buffer of the character that caused the exception. The index position in the input buffer of the character that cannot be encoded. - diff --git a/xml/System.Text/EncoderReplacementFallback.xml b/xml/System.Text/EncoderReplacementFallback.xml index b0a8e1e7833..3e9121d530b 100644 --- a/xml/System.Text/EncoderReplacementFallback.xml +++ b/xml/System.Text/EncoderReplacementFallback.xml @@ -67,30 +67,29 @@ Provides a failure handling mechanism, called a fallback, for an input character that cannot be converted to an output byte sequence. The fallback uses a user-specified replacement string instead of the original input character. This class cannot be inherited. - object cannot encode a character having a Unicode code point value that is outside the range U+0000 to U+007F. If the input character cannot be converted to an output byte sequence, a object substitutes a specified replacement string for the original input character. The conversion process encodes the replacement string and then continues to process the remainder of the original input. + + The replacement string used by an object is determined by the call to its class constructor. Two options are available: + +- Replacement with the default character. If you call the constructor, the replacement character is "?" (U+003F). + +- Replacement with a string of your choice. If you call the constructor, you provide the replacement string. + + If you choose a fallback string to use with this class, make sure that the string is composed entirely of characters that can be encoded in the target encoding. Otherwise, a recursive fallback results, causing an . + + This class is one of two .NET Framework classes that implement different fallback strategies for handling encoding conversion failures. The other class is the class, which throws an when an invalid character is encountered. + + + +## Examples + The following example demonstrates the class. -## Remarks - A common reason for an encoding or decoding operation to fail is if the underlying encoding class does not provide a mapping between a character and an equivalent byte sequence. For example, an object cannot encode a character having a Unicode code point value that is outside the range U+0000 to U+007F. If the input character cannot be converted to an output byte sequence, a object substitutes a specified replacement string for the original input character. The conversion process encodes the replacement string and then continues to process the remainder of the original input. - - The replacement string used by an object is determined by the call to its class constructor. Two options are available: - -- Replacement with the default character. If you call the constructor, the replacement character is "?" (U+003F). - -- Replacement with a string of your choice. If you call the constructor, you provide the replacement string. - - If you choose a fallback string to use with this class, make sure that the string is composed entirely of characters that can be encoded in the target encoding. Otherwise, a recursive fallback results, causing an . - - This class is one of two .NET Framework classes that implement different fallback strategies for handling encoding conversion failures. The other class is the class, which throws an when an invalid character is encountered. - - - -## Examples - The following example demonstrates the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncoderReplacementFallback/Overview/fallEncRpl.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncRpl/vb/fallEncRpl.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncRpl/vb/fallEncRpl.vb" id="Snippet1"::: + ]]> @@ -146,11 +145,11 @@ Initializes a new instance of the class. - object is "?". - + object is "?". + ]]> @@ -198,13 +197,13 @@ A string that is converted in an encoding operation in place of an input character that cannot be encoded. Initializes a new instance of the class using a specified replacement string. - object. You application must provide a `replacement` value that contains only characters that can be encoded in the target encoding. Otherwise, a recursive fallback results, causing an . For example, the fallback provided for an object cannot include the character "¿" (U+00BF) because that character is itself not a valid ASCII character. - - As a result of this, U+FFFD, which is a good choice for a fallback string for , is not generally a good choice for this class. Also, the null character (U+0000) cannot be used in the fallback string. - + object. You application must provide a `replacement` value that contains only characters that can be encoded in the target encoding. Otherwise, a recursive fallback results, causing an . For example, the fallback provided for an object cannot include the character "¿" (U+00BF) because that character is itself not a valid ASCII character. + + As a result of this, U+FFFD, which is a good choice for a fallback string for , is not generally a good choice for this class. Also, the null character (U+0000) cannot be used in the fallback string. + ]]> @@ -366,11 +365,11 @@ if the parameter specifies an object and the replacement string of that object is equal to the replacement string of this object; otherwise, . - object is the value of its property. - + object is the value of its property. + ]]> @@ -418,11 +417,11 @@ Retrieves the hash code for the value of the object. The hash code of the value of the object. - object is the value of its property. - + object is the value of its property. + ]]> diff --git a/xml/System.Text/Encoding.xml b/xml/System.Text/Encoding.xml index ed59e24cd76..9e36efb5add 100644 --- a/xml/System.Text/Encoding.xml +++ b/xml/System.Text/Encoding.xml @@ -91,7 +91,6 @@ The following example converts a string from one encoding to another. > [!NOTE] > The `byte[]` array is the only type in this example that contains the encoded data. The .NET `Char` and `String` types are themselves Unicode, so the call decodes the data back to Unicode. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/CPP/convert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/Overview/convert.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/VB/convert.vb" id="Snippet1"::: ]]> @@ -360,7 +359,6 @@ The following example converts a string from one encoding to another. The following example demonstrates the effect of the ASCII encoding on characters that are outside the ASCII range. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.ASCII Example/CPP/ascii.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/ASCII/ascii.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.ASCII Example/VB/ascii.vb" id="Snippet1"::: @@ -430,13 +428,11 @@ The following example demonstrates the effect of the ASCII encoding on character ## Examples The following example reads a text file with a UTF-16 encoding using the big endian byte order. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.BigEndianUnicode/CPP/bigendianunicode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/bigendianunicode.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.BigEndianUnicode/VB/bigendianunicode.vb" id="Snippet1"::: The following example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/getbytes_chararr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/VB/getbytes_chararr.vb" id="Snippet1"::: @@ -504,7 +500,6 @@ The following example demonstrates the effect of the ASCII encoding on character ## Examples The following example retrieves the different names for each encoding and displays the encodings with one or more names that are different from . It displays but does not compare against it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BodyName/names.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Names/VB/names.vb" id="Snippet1"::: @@ -631,7 +626,6 @@ The following example demonstrates the effect of the ASCII encoding on character ## Examples The following example retrieves the different names for each encoding and displays the encodings with one or more names that are different from . It displays but does not compare against it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BodyName/names.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Names/VB/names.vb" id="Snippet1"::: @@ -708,7 +702,6 @@ The following example demonstrates the effect of the ASCII encoding on character ## Examples The following example converts a Unicode-encoded string to an ASCII-encoded string. Because the ASCII encoding object returned by the property uses replacement fallback and the Pi character is not part of the ASCII character set, the Pi character is replaced with a question mark, as the output from the example shows. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/CPP/convert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/Overview/convert.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/VB/convert.vb" id="Snippet1"::: @@ -1118,7 +1111,6 @@ The returned 's and . It displays but does not compare against it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BodyName/names.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Names/VB/names.vb" id="Snippet1"::: @@ -1195,7 +1187,6 @@ The returned 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncoderReplacementFallback/Overview/fallEncRpl.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncRpl/vb/fallEncRpl.vb" id="Snippet1"::: @@ -3870,7 +3841,6 @@ In .NET 5 and later versions, the code page name `utf-7` is not supported. ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncoderReplacementFallback/Overview/fallEncRpl.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncRpl/vb/fallEncRpl.vb" id="Snippet1"::: @@ -3953,7 +3923,6 @@ In .NET 5 and later versions, the code page name `utf-7` is not supported. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -4080,7 +4049,6 @@ In .NET 5 and later versions, the code page name `utf-7` is not supported. ## Examples The following example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/getbytes_chararr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/VB/getbytes_chararr.vb" id="Snippet1"::: @@ -4170,7 +4138,6 @@ In .NET 5 and later versions, the code page name `utf-7` is not supported. ## Examples The following example encodes a string into an array of bytes, and then decodes the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetChars/CPP/getchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetCharCount/getchars.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetChars/VB/getchars.vb" id="Snippet1"::: @@ -4272,7 +4239,6 @@ In .NET 5 and later versions, the code page name `utf-7` is not supported. ## Examples The following example determines the byte order of the encoding based on the preamble. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetPreamble Example/CPP/preamble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetPreamble/preamble.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetPreamble Example/VB/preamble.vb" id="Snippet1"::: @@ -4683,7 +4649,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example retrieves the different names for each encoding and displays the encodings with one or more names that are different from . It displays but does not compare against it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BodyName/names.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Names/VB/names.vb" id="Snippet1"::: @@ -4874,7 +4839,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -4931,7 +4895,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -4988,7 +4951,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -5045,7 +5007,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -5164,7 +5125,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -5501,7 +5461,6 @@ Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, ## Examples The following example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/getbytes_chararr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/VB/getbytes_chararr.vb" id="Snippet1"::: @@ -5570,7 +5529,6 @@ Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, ## Examples The following example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/getbytes_chararr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/VB/getbytes_chararr.vb" id="Snippet1"::: @@ -5640,7 +5598,6 @@ Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, ## Examples The following example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/getbytes_chararr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/VB/getbytes_chararr.vb" id="Snippet1"::: @@ -5810,13 +5767,11 @@ Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, ## Examples The following example includes the in an HTML header. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.WebName/CPP/webname.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/WebName/webname.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.WebName/VB/webname.vb" id="Snippet1"::: The following example retrieves the different names for each encoding and displays the encodings with one or more names that are different from . It displays but does not compare against it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BodyName/names.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Names/VB/names.vb" id="Snippet1"::: @@ -5878,7 +5833,6 @@ Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, ## Examples The following example determines the Windows code page that most closely corresponds to each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.CodePage/CPP/codepage.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/WindowsCodePage/codepage.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.CodePage/VB/codepage.vb" id="Snippet1"::: diff --git a/xml/System.Text/EncodingInfo.xml b/xml/System.Text/EncodingInfo.xml index db117d447c3..27af0549c49 100644 --- a/xml/System.Text/EncodingInfo.xml +++ b/xml/System.Text/EncodingInfo.xml @@ -54,22 +54,21 @@ Provides basic information about an encoding. - class. The method returns an array of this type. + + This class is intended to provide minimal information about an encoding. To obtain additional information, the application should use the method to get an instance of the class, which contains more comprehensive information about the encoding it represents. + + + +## Examples + The following example uses the method to retrieve an object for each encoding supported by the .NET Framework. It then displays the value of each encoding's , , and property and compares them with the corresponding names. -## Remarks - This class is primarily used by the class. The method returns an array of this type. - - This class is intended to provide minimal information about an encoding. To obtain additional information, the application should use the method to get an instance of the class, which contains more comprehensive information about the encoding it represents. - - - -## Examples - The following example uses the method to retrieve an object for each encoding supported by the .NET Framework. It then displays the value of each encoding's , , and property and compares them with the corresponding names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: + ]]> @@ -148,20 +147,19 @@ Gets the code page identifier of the encoding. The code page identifier of the encoding. - . - - - -## Examples - The following code example retrieves the different names for each encoding and compares them with the equivalent names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp" id="Snippet1"::: + . + + + +## Examples + The following code example retrieves the different names for each encoding and compares them with the equivalent names. + :::code language="csharp" source="~/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: + ]]> @@ -205,20 +203,19 @@ Gets the human-readable description of the encoding. The human-readable description of the encoding. - property. Your applications should use for a name to pass to . - - - -## Examples - The following code example retrieves the different names for each encoding and compares them with the equivalent names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp" id="Snippet1"::: + property. Your applications should use for a name to pass to . + + + +## Examples + The following code example retrieves the different names for each encoding and compares them with the equivalent names. + :::code language="csharp" source="~/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: + ]]> @@ -275,11 +272,11 @@ if is a object and is equal to the current object; otherwise, . - objects are equal if their properties are equal. - + objects are equal if their properties are equal. + ]]> @@ -329,15 +326,14 @@ Returns a object that corresponds to the current object. A object that corresponds to the current object. - names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp" id="Snippet1"::: + names. + :::code language="csharp" source="~/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: + ]]> @@ -384,11 +380,11 @@ Returns the hash code for the current object. A 32-bit signed integer hash code. - method is not suitable for distinguishing one object from another. If your application needs a unique hash code, it should override the method. - + method is not suitable for distinguishing one object from another. If your application needs a unique hash code, it should override the method. + ]]> @@ -431,22 +427,21 @@ Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the encoding. The IANA name for the encoding. - . This name is the same as the name represented by the property. When its value is the name of a standard, the actual implementation of the encoding may not conform in full to that standard. Your applications should use for a human-readable name. - - The method gets a complete list of supported encodings, uniquely distinguished by code page. If your application retrieves encodings using the property, note that some duplicate encodings are retrieved. For more about handling these duplicates, see the description of . - + . This name is the same as the name represented by the property. When its value is the name of a standard, the actual implementation of the encoding may not conform in full to that standard. Your applications should use for a human-readable name. + + The method gets a complete list of supported encodings, uniquely distinguished by code page. If your application retrieves encodings using the property, note that some duplicate encodings are retrieved. For more about handling these duplicates, see the description of . + For a list of supported names, see [Character Sets](https://www.iana.org/assignments/character-sets/character-sets.xhtml) on the [IANA website](https://www.iana.org). - -## Examples - The following code example retrieves the different names for each encoding and compares them with the equivalent names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp" id="Snippet1"::: + +## Examples + The following code example retrieves the different names for each encoding and compares them with the equivalent names. + :::code language="csharp" source="~/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Text/StringBuilder.xml b/xml/System.Text/StringBuilder.xml index cde9833f26e..1d5e59862ae 100644 --- a/xml/System.Text/StringBuilder.xml +++ b/xml/System.Text/StringBuilder.xml @@ -79,7 +79,6 @@ class. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Overview/StringBuilder.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Overview/StringBuilder.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StringBuilder/VB/StringBuilder.vb" id="Snippet1"::: @@ -159,7 +158,6 @@ The following example shows how to call many of the methods defined by the constructor with no parameters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet1"::: @@ -229,7 +227,6 @@ The following example shows how to call many of the methods defined by the constructor with a specified capacity. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet3"::: @@ -295,7 +292,6 @@ The following example shows how to call many of the methods defined by the constructor with the specified string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet4"::: @@ -369,7 +365,6 @@ The following example shows how to call many of the methods defined by the constructor with a specified capacity and maximum capacity. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet5"::: @@ -449,7 +444,6 @@ The following example shows how to call many of the methods defined by the constructor with an initial string and a specified capacity. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet7"::: @@ -529,7 +523,6 @@ The following example shows how to call many of the methods defined by the constructor with the specified string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet6"::: @@ -2497,7 +2490,6 @@ The following example shows how to call many of the methods defined by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendFormat/appfmt.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendFormat/appfmt.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendformat/VB/appfmt.vb" id="Snippet1"::: @@ -2626,7 +2618,6 @@ The following example shows how to call many of the methods defined by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendFormat/appfmt.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendFormat/appfmt.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendformat/VB/appfmt.vb" id="Snippet1"::: @@ -2984,7 +2975,6 @@ The index of a format item is less than 0 (zero), or greater than or equal to th ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendFormat/appfmt.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendFormat/appfmt.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendformat/VB/appfmt.vb" id="Snippet1"::: @@ -3321,7 +3311,6 @@ The index of a format item is less than 0 (zero), or greater than or equal to th ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendFormat/appfmt.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendFormat/appfmt.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendformat/VB/appfmt.vb" id="Snippet1"::: @@ -3577,7 +3566,6 @@ The index of a format item is less than 0 (zero), or greater than or equal to th ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendFormat/appfmt.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendFormat/appfmt.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendformat/VB/appfmt.vb" id="Snippet1"::: @@ -4579,7 +4567,6 @@ The index of a format item is less than 0 (zero), or greater than or equal to th ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendLine/al.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendLine/al.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendline/VB/al.vb" id="Snippet1"::: @@ -4823,7 +4810,6 @@ The index of a format item is less than 0 (zero), or greater than or equal to th ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.ensurecapacity/VB/cap.vb" id="Snippet1"::: @@ -5087,7 +5073,6 @@ The following example instantiates a object wit ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/CopyTo/ct2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/CopyTo/ct2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.copyto2/VB/ct2.vb" id="Snippet1"::: @@ -5167,7 +5152,6 @@ The following example instantiates a object wit ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.ensurecapacity/VB/cap.vb" id="Snippet1"::: @@ -5297,7 +5281,6 @@ The `Equals` method performs an ordinal comparison to determine whether the char ## Examples The following code uses the method to check whether two objects are equal. The method is called repeatedly after small changes are made to each object, and the results are displayed to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.ensurecapacity/VB/cap.vb" id="Snippet1"::: @@ -5389,7 +5372,6 @@ foreach (ReadOnlyMemory chunk in sb.GetChunks()) ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Insert/insert.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Insert/insert.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.insert/VB/insert.vb" id="Snippet1"::: @@ -6804,7 +6786,6 @@ The existing characters are shifted to make room for the character sequence in t ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.ensurecapacity/VB/cap.vb" id="Snippet1"::: @@ -6936,7 +6917,6 @@ In .NET Core and in the .NET Framework 4.0 and later versions, when you instanti ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Remove/remove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Remove/remove.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.remove/VB/remove.vb" id="Snippet1"::: @@ -6964,7 +6944,6 @@ In .NET Core and in the .NET Framework 4.0 and later versions, when you instanti ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Replace/replace.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Replace/replace.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.replace/VB/replace.vb" id="Snippet1"::: @@ -7494,7 +7473,6 @@ In .NET Core and in the .NET Framework 4.0 and later versions, when you instanti ## Examples The following example demonstrates calling the method. This example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Overview/StringBuilder.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Overview/StringBuilder.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StringBuilder/VB/StringBuilder.vb" id="Snippet5"::: diff --git a/xml/System.Text/UTF32Encoding.xml b/xml/System.Text/UTF32Encoding.xml index ac1e306372c..f2f6053a918 100644 --- a/xml/System.Text/UTF32Encoding.xml +++ b/xml/System.Text/UTF32Encoding.xml @@ -105,7 +105,6 @@ ## Examples The following example demonstrates the behavior of objects with and without error detection enabled. It creates a byte array whose last four bytes represent an invalid surrogate pair; the high surrogate U+D8FF is followed by an U+01FF, which is outside the range of low surrogates (0xDC00 through 0xDFFF). Without error detection, the UTF32 decoder uses replacement fallback to replace the invalid surrogate pair with REPLACEMENT CHARACTER (U+FFFD). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/CPP/errordetection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/Overview/errordetection.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/VB/ErrorDetection.vb" id="Snippet1"::: @@ -190,7 +189,6 @@ ## Examples The following example retrieves and displays the byte order mark for different instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/.ctor/getpreamble.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/VB/GetPreamble.vb" id="Snippet1"::: @@ -252,7 +250,6 @@ ## Examples The following example retrieves and displays the byte order mark for different instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/.ctor/getpreamble.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/VB/GetPreamble.vb" id="Snippet1"::: @@ -318,7 +315,6 @@ ## Examples The following example demonstrates the behavior of , both with error detection enabled and without. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/CPP/errordetection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/Overview/errordetection.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/VB/ErrorDetection.vb" id="Snippet1"::: @@ -397,7 +393,6 @@ ## Examples The following example creates objects using different parameter values and then checks them for equality. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.Equals/CPP/equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/Equals/equals.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.Equals/VB/equals.vb" id="Snippet1"::: @@ -855,7 +850,6 @@ ## Examples The following example determines the number of bytes required to encode three characters from a character array, then encodes the characters and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetBytes/getbytes_chararr.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_CharArr/VB/GetBytes_CharArr.vb" id="Snippet1"::: @@ -964,7 +958,6 @@ ## Examples The following example determines the number of bytes required to encode a string, then encodes the string and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/CPP/getbytes_string.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetBytes/getbytes_string.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/VB/GetBytes_String.vb" id="Snippet1"::: @@ -1158,7 +1151,6 @@ ## Examples The following example encodes a string into an array of bytes, and then decodes the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetCharCount/getchars.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/VB/GetChars.vb" id="Snippet1"::: @@ -1365,7 +1357,6 @@ ## Examples The following example encodes a string into an array of bytes, and then decodes the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetCharCount/getchars.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/VB/GetChars.vb" id="Snippet1"::: @@ -1455,7 +1446,6 @@ ## Examples The following example uses an encoder and a decoder to encode a string into an array of bytes, and then decode the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/CPP/encdec.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetDecoder/encdec.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/VB/EncDec.vb" id="Snippet1"::: @@ -1521,7 +1511,6 @@ ## Examples The following example uses an encoder and a decoder to encode a string into an array of bytes, and then decode the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/CPP/encdec.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetDecoder/encdec.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/VB/EncDec.vb" id="Snippet1"::: @@ -1637,7 +1626,6 @@ ## Examples The following example determines the number of bytes required to encode a string, then encodes the string and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/CPP/getbytes_string.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetBytes/getbytes_string.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/VB/GetBytes_String.vb" id="Snippet1"::: @@ -1719,7 +1707,6 @@ ## Examples The following example encodes a string into an array of bytes, and then decodes the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetCharCount/getchars.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/VB/GetChars.vb" id="Snippet1"::: @@ -1813,7 +1800,6 @@ ## Examples The following code example retrieves and displays the byte order mark for different instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/.ctor/getpreamble.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/VB/GetPreamble.vb" id="Snippet1"::: diff --git a/xml/System.Text/UTF7Encoding.xml b/xml/System.Text/UTF7Encoding.xml index 3b3959ee35b..91ee5e3f7d1 100644 --- a/xml/System.Text/UTF7Encoding.xml +++ b/xml/System.Text/UTF7Encoding.xml @@ -86,7 +86,6 @@ ## Examples The following code example demonstrates how to use a to encode a string of Unicode characters and store them in a byte array. Notice that when the byte array is decoded back to a string, no data is lost. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding Example/CPP/snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/Overview/snippet.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding Example/VB/snippet.vb" id="Snippet1"::: @@ -164,7 +163,6 @@ ## Examples The following code example demonstrates how to create a new instance and display the name of the encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor1 Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/.ctor/ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor1 Example/VB/ctor.vb" id="Snippet1"::: @@ -232,7 +230,6 @@ ## Examples The following code example demonstrates how to create a new instance that allows optional characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor2 Example/CPP/ctor-boolean.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/.ctor/ctor-boolean.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor2 Example/VB/ctor-boolean.vb" id="Snippet1"::: @@ -382,7 +379,6 @@ ## Examples The following code example demonstrates how to use the method to return the number of bytes required to encode a character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetByteCount/getbytecount-char[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/VB/getbytecount-char[]-int32-int32.vb" id="Snippet1"::: @@ -548,7 +544,6 @@ ## Examples The following code example demonstrates how to use the method to return the number of bytes required to encode an array of Unicode characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetByteCount/getbytecount-char[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/VB/getbytecount-char[]-int32-int32.vb" id="Snippet1"::: @@ -753,7 +748,6 @@ ## Examples The following code example demonstrates how to use the method to encode a range of characters from a and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -863,7 +857,6 @@ ## Examples The following code example demonstrates how to use the method to encode a range of elements from a Unicode character array, and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1054,7 +1047,6 @@ ## Examples The following code example demonstrates how to use the method to return the number of characters produced by decoding a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetCharCount/getcharcount-byte[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: @@ -1260,7 +1252,6 @@ ## Examples The following code example demonstrates how to use the method to decode a range of elements in a byte array and store the result in a character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetChars/getchars-byte[]-int32-int32-char[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: @@ -1346,7 +1337,6 @@ ## Examples The following code example demonstrates how to use the method to obtain a decoder to convert the UTF-7 encoded bytes into a sequence of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetDecoder Example/CPP/getdecoder-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetDecoder/getdecoder-.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetDecoder Example/VB/getdecoder-.vb" id="Snippet1"::: @@ -1411,7 +1401,6 @@ ## Examples The following code example demonstrates how to use the method to obtain an encoder to convert a sequence of characters into a UTF-7 encoded sequence of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetEncoder Example/CPP/getencoder-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetEncoder/getencoder-.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetEncoder Example/VB/getencoder-.vb" id="Snippet1"::: @@ -1542,7 +1531,6 @@ ## Examples The following code example demonstrates how to use the method to return the maximum number of bytes required to encode a specified number of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetMaxByteCount/getmaxbytecount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxByteCount Example/VB/getmaxbytecount-int32.vb" id="Snippet1"::: @@ -1627,7 +1615,6 @@ ## Examples The following code example demonstrates how to use the method to return the maximum number of characters produced by decoding a specified number of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetMaxCharCount/getmaxcharcount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxCharCount Example/VB/getmaxcharcount-int32.vb" id="Snippet1"::: @@ -1720,7 +1707,6 @@ ## Examples The following code example encodes a string into an array of bytes, and then decodes the bytes back into a string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.getstring/CPP/getstring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetString/getstring.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.getstring/VB/getstring.vb" id="Snippet1"::: diff --git a/xml/System.Text/UTF8Encoding.xml b/xml/System.Text/UTF8Encoding.xml index fa109725ba7..4601e1cd32c 100644 --- a/xml/System.Text/UTF8Encoding.xml +++ b/xml/System.Text/UTF8Encoding.xml @@ -95,7 +95,6 @@ ## Examples The following example uses a object to encode a string of Unicode characters and store them in a byte array. The Unicode string includes two characters, Pi (U+03A0) and Sigma (U+03A3), that are outside the ASCII character range. When the encoded byte array is decoded back to a string, the Pi and Sigma characters are still present. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding Example/CPP/snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/Overview/snippet.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding Example/VB/snippet.vb" id="Snippet1"::: @@ -172,7 +171,6 @@ ## Examples The following example creates a new instance and displays its name. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor1 Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/.ctor/ctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor1 Example/VB/ctor.vb" id="Snippet1"::: @@ -238,7 +236,6 @@ ## Examples The following example creates a new instance and specifies that a Unicode byte order mark prefix should be emitted by the method. The method then returns the Unicode byte order mark prefix. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor2 Example/CPP/ctor-boolean.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/.ctor/ctor-boolean.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor2 Example/VB/ctor-boolean.vb" id="Snippet1"::: @@ -307,7 +304,6 @@ ## Examples The following example creates a new instance, specifying that the method should not emit a Unicode byte order mark prefix, and an exception should be thrown when an invalid encoding is detected. The behavior of this constructor is compared to the default constructor, which does not throw an exception when an invalid encoding is detected. The two instances encode a character array that contains two high surrogates (U+D801 and U+D802) in a row, which is an invalid character sequence; a high surrogate should always be followed by a low surrogate. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor3 Example/CPP/ctor-boolean-boolean.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/.ctor/ctor-boolean-boolean.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor3 Example/VB/ctor-boolean-boolean.vb" id="Snippet1"::: @@ -386,7 +382,6 @@ ## Examples The following example uses the method to test whether the current object is equal to a different object. Four objects are created and compared and the results of the comparisons are displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CPP/equals-object.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/Equals/equals-object.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/VB/equals-object.vb" id="Snippet1"::: @@ -998,7 +993,6 @@ ## Examples The following example uses the method to encode a range of characters from a string and stores the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetBytes/getbytes-string-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes3 Example/VB/getbytes-string-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1110,7 +1104,6 @@ ## Examples The following example uses the method to encode a range of elements from a Unicode character array and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes1 Example/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1357,7 +1350,6 @@ ## Examples The following example uses the method to return the number of characters produced by decoding a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetCharCount/getcharcount-byte[]-int32-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: @@ -1623,7 +1615,6 @@ ## Examples The following example uses the method to decode a range of elements in a byte array and store the result in a character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetChars/getchars-byte[]-int32-int32-char[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: @@ -1715,7 +1706,6 @@ ## Examples The following example uses the method to obtain a UTF-8 decoder. The decoder converts a sequence of bytes into a sequence of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CPP/getdecoder-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetDecoder/getdecoder-.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/VB/getdecoder-.vb" id="Snippet1"::: @@ -1783,7 +1773,6 @@ ## Examples The following example uses the method to obtain an encoder to convert a sequence of characters into a UTF-8 encoded sequence of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CPP/getencoder-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetEncoder/getencoder-.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/VB/getencoder-.vb" id="Snippet1"::: @@ -1843,7 +1832,6 @@ ## Examples The following example uses the method to return a hash code for instances. Notice that the hash code returned by this method depends on the constructor used to create the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetHashCode Example/CPP/gethashcode-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetHashCode/gethashcode-.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetHashCode Example/VB/gethashcode-.vb" id="Snippet1"::: @@ -1916,7 +1904,6 @@ ## Examples The following example uses the method to return the maximum number of bytes required to encode a specified number of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetMaxByteCount/getmaxbytecount-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/VB/getmaxbytecount-int32.vb" id="Snippet1"::: @@ -2002,7 +1989,6 @@ ## Examples The following example uses the method to return the maximum number of characters produced by decoding a specified number of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetMaxCharCount/getmaxcharcount-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/VB/getmaxcharcount-int32.vb" id="Snippet1"::: @@ -2094,7 +2080,6 @@ ## Examples The following example uses the method to return the Unicode byte order mark encoded in UTF-8 format. Notice that the parameterless constructor for does not provide a preamble. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetPreamble/getpreamble-.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/VB/getpreamble-.vb" id="Snippet1"::: diff --git a/xml/System.Text/UnicodeEncoding.xml b/xml/System.Text/UnicodeEncoding.xml index 29d0f06f82e..6fcd7ab1e86 100644 --- a/xml/System.Text/UnicodeEncoding.xml +++ b/xml/System.Text/UnicodeEncoding.xml @@ -113,7 +113,6 @@ ## Examples The following example demonstrates how to encode a string of Unicode characters into a byte array by using a object. The byte array is decoded into a string to demonstrate that there is no loss of data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding Example/CPP/snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/Overview/snippet.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding Example/VB/snippet.vb" id="Snippet1"::: @@ -195,7 +194,6 @@ ## Examples The following example demonstrates how to create a new instance and display the name of the encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/.ctor/ctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor Example/VB/ctor.vb" id="Snippet1"::: @@ -263,7 +261,6 @@ ## Examples The following example demonstrates how to create a new instance specifying whether to support little endian or big endian byte ordering and the Unicode byte order mark. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/CPP/ctor-boolean-boolean.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/.ctor/ctor-boolean-boolean.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/VB/ctor-boolean-boolean.vb" id="Snippet1"::: @@ -332,7 +329,6 @@ ## Examples The following example demonstrates the behavior of , both with error detection enabled and without. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ErrorDetection/CPP/errordetection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/.ctor/errordetection.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ErrorDetection/VB/errordetection.vb" id="Snippet1"::: @@ -390,7 +386,6 @@ ## Examples The following example demonstrates how to return the value of and display it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.CharSize Example/CPP/charsize.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/CharSize/charsize.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.CharSize Example/VB/charsize.vb" id="Snippet1"::: @@ -470,7 +465,6 @@ ## Examples The following example demonstrates how to use the method to test whether the current object is equal to a different object. Five objects are created and compared, and the results of the comparisons are displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/CPP/ctor-boolean-boolean.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/.ctor/ctor-boolean-boolean.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/VB/ctor-boolean-boolean.vb" id="Snippet1"::: @@ -976,7 +970,6 @@ ## Examples The following example demonstrates how to use the method to encode a range of characters from a and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetBytes/getbytes-string-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes3 Example/VB/getbytes-string-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1087,7 +1080,6 @@ ## Examples The following example demonstrates how to encode a range of elements from a Unicode character array and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes1 Example/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1286,7 +1278,6 @@ ## Examples The following example demonstrates how to use the method to return the number of characters produced by decoding a range of elements in a byte array using . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetCharCount/getcharcount-byte[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: @@ -1498,7 +1489,6 @@ ## Examples The following example demonstrates how to use the method to decode a range of elements in a byte array and store the result in a character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetChars/getchars-byte[]-int32-int32-char[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: @@ -1590,7 +1580,6 @@ ## Examples The following example uses an encoder and a decoder to encode a string into an array of bytes, and then decode the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/CPP/encdec.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetDecoder/encdec.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/VB/encdec.vb" id="Snippet1"::: @@ -1663,7 +1652,6 @@ ## Examples The following example uses an encoder and a decoder to encode a string into an array of bytes, and then decode the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/CPP/encdec.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetDecoder/encdec.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/VB/encdec.vb" id="Snippet1"::: @@ -1785,7 +1773,6 @@ ## Examples The following example demonstrates how to use the method to return the maximum number of bytes required to encode a specified number of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetMaxByteCount/getmaxbytecount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxByteCount Example/VB/getmaxbytecount-int32.vb" id="Snippet1"::: @@ -1871,7 +1858,6 @@ ## Examples The following example demonstrates how to use the method to return the maximum number of characters produced by decoding a specified number of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetMaxCharCount/getmaxcharcount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxCharCount Example/VB/getmaxcharcount-int32.vb" id="Snippet1"::: @@ -1967,7 +1953,6 @@ ## Examples The following example demonstrates how to use the method to retrieve the Unicode byte order mark in big endian or little endian byte order for an instance of a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetPreamble Example/CPP/getpreamble-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetPreamble/getpreamble-.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetPreamble Example/VB/getpreamble-.vb" id="Snippet1"::: diff --git a/xml/System.Threading/AbandonedMutexException.xml b/xml/System.Threading/AbandonedMutexException.xml index 79d57cdd8a0..3b4e5fb73f8 100644 --- a/xml/System.Threading/AbandonedMutexException.xml +++ b/xml/System.Threading/AbandonedMutexException.xml @@ -84,7 +84,6 @@ > [!NOTE] > The call to the method is interrupted by one of the abandoned mutexes. The other abandoned mutex could still cause an to be thrown by subsequent wait methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/CPP/koax.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/AbandonedMutexException/Overview/koax.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/VB/koax.vb" id="Snippet1"::: @@ -654,7 +653,6 @@ > [!NOTE] > The call to is interrupted by one of the abandoned mutexes. The other abandoned mutex could still cause an to be thrown by subsequent wait methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/CPP/koax.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/AbandonedMutexException/Overview/koax.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/VB/koax.vb" id="Snippet1"::: diff --git a/xml/System.Threading/ApartmentState.xml b/xml/System.Threading/ApartmentState.xml index ad24f5ff9cd..f2899077d78 100644 --- a/xml/System.Threading/ApartmentState.xml +++ b/xml/System.Threading/ApartmentState.xml @@ -54,24 +54,22 @@ Specifies the apartment state of a . - property of the thread to one of the values of the enumeration. Because a given thread can only initialize a COM apartment once, you cannot change the apartment type after the first call to the unmanaged code. - - For more information, see , [Managed and Unmanaged Threading](https://msdn.microsoft.com/library/db425c20-4b2f-4433-bf96-76071c7881e5), and [Advanced COM Interoperability](https://msdn.microsoft.com/library/3ada36e5-2390-4d70-b490-6ad8de92f2fb). - - - -## Examples - The following code example demonstrates how to set the apartment state of a thread. - + property of the thread to one of the values of the enumeration. Because a given thread can only initialize a COM apartment once, you cannot change the apartment type after the first call to the unmanaged code. + + For more information, see , [Managed and Unmanaged Threading](/previous-versions/dotnet/netframework-4.0/5s8ee185(v=vs.100)), and [Advanced COM Interoperability](/previous-versions/dotnet/netframework-4.0/bd9cdfyx(v=vs.100)). + +## Examples + The following code example demonstrates how to set the apartment state of a thread. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ApartmentState/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ApartmentState/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.ApartmentState/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.ApartmentState/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Threading/AutoResetEvent.xml b/xml/System.Threading/AutoResetEvent.xml index 6efeac22bcb..51552ecfdde 100644 --- a/xml/System.Threading/AutoResetEvent.xml +++ b/xml/System.Threading/AutoResetEvent.xml @@ -90,7 +90,6 @@ The following example shows how to use to After the threads are released from the first , they wait on another that was created in the non-signaled state. All three threads block, so the method must be called three times to release them all. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/simplerisbetter.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/AutoResetEvent/Overview/simplerisbetter.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/VB/simplerisbetter.vb" id="Snippet3"::: @@ -161,7 +160,6 @@ After the threads are released from the first method, to give the second thread a chance to execute. Otherwise, on a single-processor computer `Main` would write many values between any two read operations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/AutoResetEvent/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/VB/class1.vb" id="Snippet1"::: diff --git a/xml/System.Threading/EventResetMode.xml b/xml/System.Threading/EventResetMode.xml index 260cd15c1b7..af5936640d0 100644 --- a/xml/System.Threading/EventResetMode.xml +++ b/xml/System.Threading/EventResetMode.xml @@ -51,17 +51,16 @@ Indicates whether an is reset automatically or manually after receiving a signal. - method overload to allow the main thread to signal a blocked thread and then wait until the thread finishes a task. + + The example starts five threads and allows them to block on an created with the AutoReset flag, then releases one thread each time the user presses the ENTER key. The example then queues another five threads and releases them all using an created with the ManualReset flag. -## Examples - The following code example uses the method overload to allow the main thread to signal a blocked thread and then wait until the thread finishes a task. - - The example starts five threads and allows them to block on an created with the AutoReset flag, then releases one thread each time the user presses the ENTER key. The example then queues another five threads and releases them all using an created with the ManualReset flag. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventResetMode/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Threading/EventWaitHandle.xml b/xml/System.Threading/EventWaitHandle.xml index 8a836999702..0f063d873ce 100644 --- a/xml/System.Threading/EventWaitHandle.xml +++ b/xml/System.Threading/EventWaitHandle.xml @@ -83,7 +83,6 @@ The class allows threads to communicate The example starts five threads and allows them to block on an created with the flag, then releases one thread each time the user presses the Enter key. The example then queues another five threads and releases them all using an created with the flag. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventResetMode/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: @@ -167,7 +166,6 @@ The class allows threads to communicate The example starts five threads and allows them to block on an created with the flag, then releases one thread each time the user presses the Enter key. The example then queues another five threads and releases them all using an created with the flag. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventResetMode/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: @@ -462,7 +460,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the event is opened with the rights required to wait on it and signal it. If you run the compiled example from a third command window, the example runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventWaitHandle/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/VB/source.vb" id="Snippet1"::: @@ -571,7 +568,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions have been read, using the method, and changed, the event is opened with the rights required to wait on it and signal it. If you run the compiled example from a third command window, the example runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventWaitHandle/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/VB/source.vb" id="Snippet1"::: @@ -750,7 +746,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the event is opened with the rights required to wait on it and signal it. If you run the compiled example from a third command window, the example runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventWaitHandle/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/VB/source.vb" id="Snippet1"::: @@ -931,7 +926,6 @@ There was some other error. The `HResult` property may provide more information. The example starts five threads and allows them to block on an created with the flag, then releases one thread each time the user presses the Enter key. The example then queues another five threads and releases them all using an created with the flag. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventResetMode/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: @@ -990,7 +984,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, using the method, the event is opened with the rights required to wait on it and signal it. If you run the compiled example from a third command window, the example runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventWaitHandle/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/Interlocked.xml b/xml/System.Threading/Interlocked.xml index b418458b428..0b5a99cdae5 100644 --- a/xml/System.Threading/Interlocked.xml +++ b/xml/System.Threading/Interlocked.xml @@ -86,7 +86,6 @@ ## Examples The following code example shows a thread-safe resource locking mechanism. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Interlocked/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/VB/class1.vb" id="Snippet1"::: @@ -738,7 +737,6 @@ > [!NOTE] > The method, introduced in version 2.0 of the .NET Framework, provides a more convenient way to accumulate thread-safe running totals for integers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked CompareExchange0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Interlocked/CompareExchange/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Interlocked CompareExchange0/VB/source.vb" id="Snippet1"::: @@ -1811,7 +1809,6 @@ If `comparand` and the object in `location1` are equal by reference, then `value ## Examples The following code example shows a thread-safe resource locking mechanism. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Interlocked/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/VB/class1.vb" id="Snippet1"::: diff --git a/xml/System.Threading/LockCookie.xml b/xml/System.Threading/LockCookie.xml index b9ac638b7c5..a670352bd16 100644 --- a/xml/System.Threading/LockCookie.xml +++ b/xml/System.Threading/LockCookie.xml @@ -63,23 +63,20 @@ Defines the lock that implements single-writer/multiple-reader semantics. This is a value type. - . It then uses the to downgrade to a reader lock again. + + This code is part of a larger example provided for the class. -## Examples - The following example shows how to request a reader lock, upgrade the reader lock to a writer lock, and save the . It then uses the to downgrade to a reader lock again. - - This code is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet5"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: + ]]> This type is thread safe. diff --git a/xml/System.Threading/ManualResetEvent.xml b/xml/System.Threading/ManualResetEvent.xml index 7623cf6269b..f652f645054 100644 --- a/xml/System.Threading/ManualResetEvent.xml +++ b/xml/System.Threading/ManualResetEvent.xml @@ -59,40 +59,39 @@ Represents a thread synchronization event that, when signaled, must be reset manually. This class cannot be inherited. - , and for thread interaction (or thread signaling). For more information, see the [Thread interaction, or signaling](/dotnet/standard/threading/overview-of-synchronization-primitives#thread-interaction-or-signaling) section of the [Overview of synchronization primitives](/dotnet/standard/threading/overview-of-synchronization-primitives) article. +## Remarks - When a thread begins an activity that must complete before other threads proceed, it calls [ManualResetEvent.Reset](xref:System.Threading.EventWaitHandle.Reset%2A) to put `ManualResetEvent` in the non-signaled state. This thread can be thought of as controlling the `ManualResetEvent`. Threads that call [ManualResetEvent.WaitOne](xref:System.Threading.WaitHandle.WaitOne%2A) block, awaiting the signal. When the controlling thread completes the activity, it calls [ManualResetEvent.Set](xref:System.Threading.EventWaitHandle.Set%2A) to signal that the waiting threads can proceed. All waiting threads are released. + You use `ManualResetEvent`, , and for thread interaction (or thread signaling). For more information, see the [Thread interaction, or signaling](/dotnet/standard/threading/overview-of-synchronization-primitives#thread-interaction-or-signaling) section of the [Overview of synchronization primitives](/dotnet/standard/threading/overview-of-synchronization-primitives) article. - Once it has been signaled, `ManualResetEvent` remains signaled until it is manually reset by calling the method. That is, calls to return immediately. + When a thread begins an activity that must complete before other threads proceed, it calls [ManualResetEvent.Reset](xref:System.Threading.EventWaitHandle.Reset%2A) to put `ManualResetEvent` in the non-signaled state. This thread can be thought of as controlling the `ManualResetEvent`. Threads that call [ManualResetEvent.WaitOne](xref:System.Threading.WaitHandle.WaitOne%2A) block, awaiting the signal. When the controlling thread completes the activity, it calls [ManualResetEvent.Set](xref:System.Threading.EventWaitHandle.Set%2A) to signal that the waiting threads can proceed. All waiting threads are released. + + Once it has been signaled, `ManualResetEvent` remains signaled until it is manually reset by calling the method. That is, calls to return immediately. + + You can control the initial state of a `ManualResetEvent` by passing a Boolean value to the constructor: `true` if the initial state is signaled, and `false` otherwise. + + `ManualResetEvent` can also be used with the `static` and methods. + + Beginning with the .NET Framework version 2.0, derives from the class. A is functionally equivalent to an created with . - You can control the initial state of a `ManualResetEvent` by passing a Boolean value to the constructor: `true` if the initial state is signaled, and `false` otherwise. - - `ManualResetEvent` can also be used with the `static` and methods. - - Beginning with the .NET Framework version 2.0, derives from the class. A is functionally equivalent to an created with . - > [!NOTE] -> Unlike the class, the class provides access to named system synchronization events. +> Unlike the class, the class provides access to named system synchronization events. - Beginning with the .NET Framework version 4.0, the class is a lightweight alternative to . - - - -## Examples - The following example demonstrates how works. The example starts with a in the unsignaled state (that is, `false` is passed to the constructor). The example creates three threads, each of which blocks on the by calling its method. When the user presses the **Enter** key, the example calls the method, which releases all three threads. Contrast this with the behavior of the class, which releases threads one at a time, resetting automatically after each release. - - Pressing the **Enter** key again demonstrates that the remains in the signaled state until its method is called: The example starts two more threads. These threads do not block when they call the method, but instead run to completion. - - Pressing the **Enter** key again causes the example to call the method and to start one more thread, which blocks when it calls . Pressing the **Enter** key one final time calls to release the last thread, and the program ends. + Beginning with the .NET Framework version 4.0, the class is a lightweight alternative to . + + + +## Examples + The following example demonstrates how works. The example starts with a in the unsignaled state (that is, `false` is passed to the constructor). The example creates three threads, each of which blocks on the by calling its method. When the user presses the **Enter** key, the example calls the method, which releases all three threads. Contrast this with the behavior of the class, which releases threads one at a time, resetting automatically after each release. + + Pressing the **Enter** key again demonstrates that the remains in the signaled state until its method is called: The example starts two more threads. These threads do not block when they call the method, but instead run to completion. + + Pressing the **Enter** key again causes the example to call the method and to start one more thread, which blocks when it calls . Pressing the **Enter** key one final time calls to release the last thread, and the program ends. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ManualResetEvent/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/VB/source.vb" id="Snippet1"::: + ]]> This class is thread safe. @@ -149,11 +148,11 @@ to set the initial state signaled; to set the initial state to nonsignaled. Initializes a new instance of the class with a Boolean value indicating whether to set the initial state to signaled. - is signaled (that is, if it is created by passing `true` for `initialState`), threads that wait on the do not block. If the initial state is nonsignaled, threads block until the method is called. - + is signaled (that is, if it is created by passing `true` for `initialState`), threads that wait on the do not block. If the initial state is nonsignaled, threads block until the method is called. + ]]> @@ -219,7 +218,7 @@ method is called. ]]> diff --git a/xml/System.Threading/Monitor.xml b/xml/System.Threading/Monitor.xml index fda694888a8..2dcb4b80a36 100644 --- a/xml/System.Threading/Monitor.xml +++ b/xml/System.Threading/Monitor.xml @@ -144,7 +144,6 @@ ## Examples The following example demonstrates how to use the `Enter` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Monitor/Enter/monitor2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MonitorExmpl2/VB/monitor2.vb" id="Snippet1"::: @@ -303,7 +302,6 @@ ## Examples The following example demonstrates how to use the `Exit` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Monitor/Enter/monitor2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MonitorExmpl2/VB/monitor2.vb" id="Snippet1"::: @@ -637,7 +635,6 @@ ## Examples The following code example demonstrates how to use the `TryEnter` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Monitor/Enter/monitor2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MonitorExmpl2/VB/monitor2.vb" id="Snippet1"::: diff --git a/xml/System.Threading/Mutex.xml b/xml/System.Threading/Mutex.xml index 043248780c8..ab4659ef967 100644 --- a/xml/System.Threading/Mutex.xml +++ b/xml/System.Threading/Mutex.xml @@ -185,7 +185,6 @@ ## Examples The following code example shows how a local object is used to synchronize access to a protected resource. The thread that creates the mutex does not own it initially. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/class13.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/VB/class1.vb" id="Snippet1"::: @@ -252,7 +251,6 @@ ## Examples The following code example shows how a local object is used to synchronize access to a protected resource. The thread that creates the owns it initially. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 1Arg Ctor Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex 1Arg Ctor Example/VB/class1.vb" id="Snippet1"::: @@ -349,7 +347,6 @@ The constructor overload used in this example cannot tell the calling thread whether initial ownership of the named mutex was granted. You should not use this constructor to request initial ownership unless you can be certain that the thread will create the named mutex. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 2Arg Ctor Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/class11.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex 2Arg Ctor Example/VB/class1.vb" id="Snippet1"::: @@ -485,7 +482,6 @@ There was some other error. The `HResult` property may provide more information. ## Examples The following code example shows how a named mutex is used to signal between processes or threads. Run this program from two or more command windows. Each process creates a object that represents the named mutex "MyMutex". The named mutex is a system object. In this example, its lifetime is bounded by the lifetimes of the objects that represent it. The named mutex is created when the first process creates its local object, and destroyed when all the objects that represent it have been released. The named mutex is initially owned by the first process. The second process and any subsequent processes wait for earlier processes to release the named mutex. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 3Arg Ctor Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/class12.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex 3Arg Ctor Example/VB/class1.vb" id="Snippet1"::: @@ -623,7 +619,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/VB/source.vb" id="Snippet1"::: @@ -728,7 +723,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/VB/source.vb" id="Snippet1"::: @@ -830,7 +824,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/VB/source.vb" id="Snippet1"::: @@ -920,7 +913,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/VB/source.vb" id="Snippet1"::: @@ -1052,7 +1044,6 @@ There was some other error. The `HResult` property may provide more information. ## Examples The following example shows how a local object is used to synchronize access to a protected resource. The thread that creates the mutex does not own it initially. The method is used to release the mutex when it is no longer needed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/class13.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/VB/class1.vb" id="Snippet1"::: @@ -1116,7 +1107,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/ParameterizedThreadStart.xml b/xml/System.Threading/ParameterizedThreadStart.xml index f821ca9a38d..5b39bd19359 100644 --- a/xml/System.Threading/ParameterizedThreadStart.xml +++ b/xml/System.Threading/ParameterizedThreadStart.xml @@ -88,7 +88,6 @@ > [!NOTE] > The Visual Basic and C# compilers infer the delegate from the signatures of the `DoWork` and `DoMoreWork` methods, and call the correct constructor. Thus, there is no explicit constructor call in the code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ParameterizedThreadStart/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/ReaderWriterLock.xml b/xml/System.Threading/ReaderWriterLock.xml index 63bda1412e9..b596e6bf407 100644 --- a/xml/System.Threading/ReaderWriterLock.xml +++ b/xml/System.Threading/ReaderWriterLock.xml @@ -97,7 +97,6 @@ ## Examples The following example demonstrates how to use a to protect a shared resource, an integer value named `resource`, that is read concurrently and written exclusively by multiple threads. Note that the is declared at the class level so that it is visible to all threads. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet1"::: @@ -156,10 +155,8 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -252,13 +249,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -425,13 +419,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -581,13 +572,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -662,13 +650,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -779,7 +764,6 @@ ## Examples The following code example demonstrates how to use `IsReaderLockHeld` to avoid deadlocks. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ReaderWriterLock/IsReaderLockHeld/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/VB/source.vb" id="Snippet1"::: @@ -844,7 +828,6 @@ ## Examples The following code example demonstrates that when an attempt is made to acquire a reader lock on a thread that has a writer lock, `ReaderWriterLock` does not grant the reader lock but instead increments the lock count on the writer lock. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ReaderWriterLock/IsReaderLockHeld/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/VB/source.vb" id="Snippet1"::: @@ -912,13 +895,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -992,13 +972,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -1073,13 +1050,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -1161,13 +1135,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -1262,13 +1233,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -1414,13 +1382,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: diff --git a/xml/System.Threading/RegisteredWaitHandle.xml b/xml/System.Threading/RegisteredWaitHandle.xml index 2c49a62fa66..ed83f43c047 100644 --- a/xml/System.Threading/RegisteredWaitHandle.xml +++ b/xml/System.Threading/RegisteredWaitHandle.xml @@ -61,23 +61,22 @@ Represents a handle that has been registered when calling . This class cannot be inherited. - to determine why a callback method is called, and how to unregister a task if the callback occurred because the wait handle was signaled. + + The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc`, and the wait handle is an . + + The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object so that the callback method has access to the . + + In addition to specifying `TaskInfo` as the object to pass to the callback method, the call to the method specifies the that the task will wait for, a delegate that represents the `WaitProc` callback method, a one second time-out interval, and multiple callbacks. + + When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a time-out occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping additional callbacks. In the case of a time-out, the task continues to wait. The `WaitProc` method ends by printing a message to the console. -## Examples - The following example shows how to use a to determine why a callback method is called, and how to unregister a task if the callback occurred because the wait handle was signaled. - - The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc`, and the wait handle is an . - - The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object so that the callback method has access to the . - - In addition to specifying `TaskInfo` as the object to pass to the callback method, the call to the method specifies the that the task will wait for, a delegate that represents the `WaitProc` callback method, a one second time-out interval, and multiple callbacks. - - When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a time-out occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping additional callbacks. In the case of a time-out, the task continues to wait. The `WaitProc` method ends by printing a message to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/RegisteredWaitHandle/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: + ]]> This type is thread safe. @@ -167,28 +166,27 @@ if the function succeeds; otherwise, . - is successfully unregistered. If a callback method is in progress when executes, `waitObject` is not signaled until the callback method completes. In particular, if a callback method executes , `waitObject` is not signaled until that callback method completes. - - - -## Examples - The following example shows how to use the method to unregister a task if a callback occurred because the wait handle was signaled. - - The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc`, and the wait handle is an . - - The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object so that the callback method has access to the . - - In addition to specifying `TaskInfo` as the object to pass to the callback method, the call to the method specifies the that the task will wait for, a delegate that represents the `WaitProc` callback method, a one second time-out interval, and multiple callbacks. - - When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a time-out occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping additional callbacks. In the case of a time-out, the task continues to wait. The `WaitProc` method ends by printing a message to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp" id="Snippet1"::: + is successfully unregistered. If a callback method is in progress when executes, `waitObject` is not signaled until the callback method completes. In particular, if a callback method executes , `waitObject` is not signaled until that callback method completes. + + + +## Examples + The following example shows how to use the method to unregister a task if a callback occurred because the wait handle was signaled. + + The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc`, and the wait handle is an . + + The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object so that the callback method has access to the . + + In addition to specifying `TaskInfo` as the object to pass to the callback method, the call to the method specifies the that the task will wait for, a delegate that represents the `WaitProc` callback method, a one second time-out interval, and multiple callbacks. + + When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a time-out occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping additional callbacks. In the case of a time-out, the task continues to wait. The `WaitProc` method ends by printing a message to the console. + :::code language="csharp" source="~/snippets/csharp/System.Threading/RegisteredWaitHandle/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: + ]]> The managed thread pool diff --git a/xml/System.Threading/Semaphore.xml b/xml/System.Threading/Semaphore.xml index fe9df5c4e5c..2ca6f2c6f56 100644 --- a/xml/System.Threading/Semaphore.xml +++ b/xml/System.Threading/Semaphore.xml @@ -81,7 +81,6 @@ ## Examples The following code example creates a semaphore with a maximum count of three and an initial count of zero. The example starts five threads, which block waiting for the semaphore. The main thread uses the method overload to increase the semaphore count to its maximum, allowing three threads to enter the semaphore. Each thread uses the method to wait for one second, to simulate work, and then calls the method overload to release the semaphore. Each time the semaphore is released, the previous semaphore count is displayed. Console messages track semaphore use. The simulated work interval is increased slightly for each thread, to make the output easier to read. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore2/VB/source.vb" id="Snippet1"::: @@ -167,7 +166,6 @@ ## Examples The following example creates a semaphore with a maximum count of three and an initial count of zero. The example starts five threads, which block waiting for the semaphore. The main thread uses the method overload to increase the semaphore count to its maximum, allowing three threads to enter the semaphore. Each thread uses the method to wait for one second, to simulate work, and then calls the method overload to release the semaphore. Each time the semaphore is released, the previous semaphore count is displayed. Console messages track semaphore use. The simulated work interval is increased slightly for each thread, to make the output easier to read. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore2/VB/source.vb" id="Snippet1"::: @@ -258,7 +256,6 @@ ## Examples The following code example demonstrates the cross-process behavior of a named semaphore. The example creates a named semaphore with a maximum count of five and an initial count of five. The program makes three calls to the method. Thus, if you run the compiled example from two command windows, the second copy will block on the third call to . Release one or more entries in the first copy of the program to unblock the second. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 3/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 3/VB/source.vb" id="Snippet1"::: @@ -368,7 +365,6 @@ There was some other error. The `HResult` property may provide more information. ## Examples The following code example demonstrates the cross-process behavior of a named semaphore. The example creates a named semaphore with a maximum count of five and an initial count of two. That is, it reserves three entries for the thread that calls the constructor. If `createNew` is `false`, the program makes three calls to the method. Thus, if you run the compiled example from two command windows, the second copy will block on the third call to . Release one or more entries in the first copy of the program to unblock the second. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 4/VB/source.vb" id="Snippet1"::: @@ -501,7 +497,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the semaphore is opened with the rights required to enter and release. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/VB/source.vb" id="Snippet1"::: @@ -615,7 +610,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the semaphore is opened with the rights required to enter and release. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/VB/source.vb" id="Snippet1"::: @@ -721,7 +715,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the semaphore is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/VB/source.vb" id="Snippet1"::: @@ -804,7 +797,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the semaphore is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/VB/source.vb" id="Snippet1"::: @@ -952,7 +944,6 @@ There was some other error. The `HResult` property may provide more information. Each time the semaphore is released, the previous semaphore count is displayed. Console messages track semaphore use. The simulated work interval is increased slightly for each thread, to make the output easier to read. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore2/VB/source.vb" id="Snippet1"::: @@ -1035,7 +1026,6 @@ There was some other error. The `HResult` property may provide more information. Each time the semaphore is released, the previous semaphore count is displayed. Console messages track semaphore use. The simulated work interval is increased slightly for each thread, to make the output easier to read. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore2/VB/source.vb" id="Snippet1"::: @@ -1101,7 +1091,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, using the method, the semaphore is opened with the rights required to enter and release. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/SemaphoreFullException.xml b/xml/System.Threading/SemaphoreFullException.xml index fb960cfa727..dbaa17f81ab 100644 --- a/xml/System.Threading/SemaphoreFullException.xml +++ b/xml/System.Threading/SemaphoreFullException.xml @@ -93,7 +93,6 @@ ## Examples The following code example shows how a programming error in one thread can lead to a in another thread: Two threads enter a semaphore. The second thread releases the semaphore twice, while the first thread is still executing its task. When the first thread finishes and releases the semaphore, the semaphore count is already full and an exception is thrown. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.SemaphoreFullException/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/SemaphoreFullException/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.SemaphoreFullException/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/Thread.xml b/xml/System.Threading/Thread.xml index bfdf373abc4..5619e4a4e7e 100644 --- a/xml/System.Threading/Thread.xml +++ b/xml/System.Threading/Thread.xml @@ -155,7 +155,6 @@ ## Examples The following example shows the syntax for creating and using a delegate with a static method and an instance method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ParameterizedThreadStart/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/ParameterizedThreadStart/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/VB/source.vb" id="Snippet1"::: @@ -227,14 +226,12 @@ ## Examples The following code example shows how to create a thread that executes a static method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/.ctor/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/.ctor/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.ctor/VB/source.vb" id="Snippet1"::: The following code example shows how to create a thread that executes an instance method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/.ctor/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/.ctor/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.ctor2/VB/source.vb" id="Snippet1"::: @@ -601,7 +598,6 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ ## Examples The following code example shows how to pass information to a thread that is being aborted. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Abort/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Abort/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/VB/source.vb" id="Snippet1"::: @@ -677,7 +673,6 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -686,7 +681,6 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ The following code example demonstrates how to use a data slot to store thread-specific information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/VB/source.vb" id="Snippet1"::: @@ -763,7 +757,6 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -775,7 +768,6 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ > [!NOTE] > The example code does not use the method, because the method allocates the slot if it has not already been allocated. If the method is used, it should be called in the main thread at program startup. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateNamedDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateNamedDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/VB/source.vb" id="Snippet1"::: @@ -857,7 +849,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following code example demonstrates how to set the apartment state of a thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ApartmentState/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ApartmentState/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/ApartmentState/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.ApartmentState/VB/source.vb" id="Snippet1"::: @@ -932,7 +923,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following example demonstrates the use of the and methods to divide a block of code into critical and non-critical regions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/BeginCriticalRegion/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/BeginCriticalRegion/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/VB/source.vb" id="Snippet1"::: @@ -1002,7 +992,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following example demonstrates the use of the and methods to notify a host that a block of code depends on the identity of a physical operating system thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/BeginThreadAffinity/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/BeginThreadAffinity/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/VB/source.vb" id="Snippet1"::: @@ -1112,7 +1101,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following example shows the threading statement that allows the user interface of a Windows Forms application to display in the culture that is set in Control Panel. Additional code is needed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Culture/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/CurrentCulture/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/CurrentCulture/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Culture/VB/source.vb" id="Snippet1"::: @@ -1186,7 +1174,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following code example shows how to set and retrieve the principal of a thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.CurrentPrincipal/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/CurrentPrincipal/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/CurrentPrincipal/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.CurrentPrincipal/VB/source.vb" id="Snippet1"::: @@ -1336,7 +1323,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR The following code example shows the threading statement that allows the user interface of a Windows Forms to display in the culture that is set in Control Panel. Additional code is needed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Culture/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/CurrentCulture/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/CurrentCulture/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Culture/VB/source.vb" id="Snippet1"::: @@ -1474,7 +1460,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following example demonstrates the use of the and methods to divide a block of code into critical and non-critical regions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/BeginCriticalRegion/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/BeginCriticalRegion/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/VB/source.vb" id="Snippet1"::: @@ -1544,7 +1529,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following example demonstrates the use of the and methods to notify a host that a block of code depends on the identity of a physical operating system thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/BeginThreadAffinity/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/BeginThreadAffinity/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/VB/source.vb" id="Snippet1"::: @@ -1735,7 +1719,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -1744,7 +1727,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR The following example demonstrates how to use a named data slot to store thread-specific information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateNamedDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateNamedDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/VB/source.vb" id="Snippet1"::: @@ -1810,7 +1792,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR After the thread is started, the method is used again. This time it throws because the thread has already been started. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/GetApartmentState/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/GetApartmentState/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/vb/source.vb" id="Snippet1"::: @@ -1998,7 +1979,6 @@ The value is not guaranteed to be a zero-based processor number. The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -2007,7 +1987,6 @@ The value is not guaranteed to be a zero-based processor number. The following example demonstrates how to use a data slot to store thread-specific information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/VB/source.vb" id="Snippet1"::: @@ -2070,7 +2049,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following code example shows how to retrieve the name and ID of the `AppDomain` in which the thread is running. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Domain/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/GetDomain/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/GetDomain/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Domain/VB/source.vb" id="Snippet1"::: @@ -2130,7 +2108,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following code example shows how to retrieve the name and ID of the `AppDomain` in which the thread is running. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Domain/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/GetDomain/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/GetDomain/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Domain/VB/source.vb" id="Snippet1"::: @@ -2254,7 +2231,6 @@ The value is not guaranteed to be a zero-based processor number. The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -2263,7 +2239,6 @@ The value is not guaranteed to be a zero-based processor number. The following example demonstrates how to use a named data slot to store thread-specific information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateNamedDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateNamedDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/VB/source.vb" id="Snippet1"::: @@ -2329,7 +2304,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following code example shows the behavior of a running thread when it is interrupted and subsequently gets blocked. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Interrupt/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Interrupt/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/VB/source.vb" id="Snippet1"::: @@ -2464,7 +2438,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following example contrasts the behavior of foreground and background threads. It creates a foreground thread and a background thread. The foreground thread keeps the process running until completes its `for` loop and terminates. However, as the output from the example shows, because the foreground thread has finished execution, the process is terminated before the background thread has completed execution. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsBackground/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/IsBackground/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/IsBackground/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.IsBackground/VB/source.vb" id="Snippet1"::: @@ -2529,7 +2502,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following code example shows how to determine whether a thread is from the thread pool. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsThreadPoolThread/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/IsThreadPoolThread/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/IsThreadPoolThread/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.IsThreadPoolThread/VB/source.vb" id="Snippet1"::: @@ -2757,7 +2729,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following code example demonstrates how to use a `TimeSpan` value with the `Join` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Timespan/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Join/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Join/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Timespan/VB/source.vb" id="Snippet1"::: @@ -3234,7 +3205,6 @@ The value is not guaranteed to be a zero-based processor number. After the thread is started, the method is used again. This time it throws because the thread has already been started. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/GetApartmentState/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/GetApartmentState/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/vb/source.vb" id="Snippet1"::: @@ -3388,7 +3358,6 @@ The value is not guaranteed to be a zero-based processor number. The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -3397,7 +3366,6 @@ The value is not guaranteed to be a zero-based processor number. The following example demonstrates how to use a named data slot to store thread-specific information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateNamedDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateNamedDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/VB/source.vb" id="Snippet1"::: @@ -3485,7 +3453,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following example uses the method to block the application's main thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Sleep/example.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Sleep/example.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/thread.sleep/vb/example.vb" id="Snippet1"::: @@ -3555,7 +3522,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following example uses the method overload to block the application's main thread five times, for two seconds each time. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Sleep/example1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Sleep/example1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/thread.sleep_timespan/vb/example.vb" id="Snippet1"::: @@ -3706,7 +3672,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following example creates and starts a thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Start/threadstart.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Start/threadstart.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ThreadStart/VB/threadstart.vb" id="Snippet1"::: @@ -3784,7 +3749,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following example creates a delegate with a static method and an instance method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ParameterizedThreadStart/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/ParameterizedThreadStart/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/VB/source.vb" id="Snippet1"::: @@ -4130,7 +4094,6 @@ When you call the `Suspend` method on a thread, the system notes that a thread s ## Examples The following code example demonstrates accessing the `ThreadState` of a thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.threading.thread.threadstate/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/ThreadState/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/ThreadState/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.threading.thread.threadstate/vb/source.vb" id="Snippet1"::: @@ -4203,7 +4166,6 @@ When you call the `Suspend` method on a thread, the system notes that a thread s After the thread is started, the method is used again. This time it throws because the thread has already been started. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/GetApartmentState/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/GetApartmentState/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/vb/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/ThreadAbortException.xml b/xml/System.Threading/ThreadAbortException.xml index 0319fd6e9dc..71e607515ff 100644 --- a/xml/System.Threading/ThreadAbortException.xml +++ b/xml/System.Threading/ThreadAbortException.xml @@ -59,41 +59,40 @@ The exception that is thrown when a call is made to the method. This class cannot be inherited. - method to destroy a thread, the common language runtime throws a on .NET Framework. is a special exception that can be caught, but it will automatically be raised again at the end of the `catch` block. When this exception is raised, the runtime executes all the `finally` blocks before ending the thread. Because the thread can do an unbounded computation in the `finally` blocks or call to cancel the abort, there is no guarantee that the thread will ever end. If you want to wait until the aborted thread has ended, you can call the method. is a blocking call that does not return until the thread actually stops executing. - + method to destroy a thread, the common language runtime throws a on .NET Framework. is a special exception that can be caught, but it will automatically be raised again at the end of the `catch` block. When this exception is raised, the runtime executes all the `finally` blocks before ending the thread. Because the thread can do an unbounded computation in the `finally` blocks or call to cancel the abort, there is no guarantee that the thread will ever end. If you want to wait until the aborted thread has ended, you can call the method. is a blocking call that does not return until the thread actually stops executing. + > [!NOTE] > **.NET Core and .NET 5+ only:** Even though this type exists in .NET Core and .NET 5+, since is not supported, the common language runtime won't ever throw . > [!NOTE] -> When the common language runtime (CLR) stops background threads after all foreground threads in a managed executable have ended, it does not use . Therefore, you cannot use to detect when background threads are being terminated by the CLR. - - uses `HRESULT COR_E_THREADABORTED`, which has the value `0x80131530`. - +> When the common language runtime (CLR) stops background threads after all foreground threads in a managed executable have ended, it does not use . Therefore, you cannot use to detect when background threads are being terminated by the CLR. + + uses `HRESULT COR_E_THREADABORTED`, which has the value `0x80131530`. + > [!NOTE] > The value of the inherited property is always `null`. + +## Examples + The following example demonstrates aborting a thread. The thread that receives the `ThreadAbortException` uses the method to cancel the abort request and continue executing. -## Examples - The following example demonstrates aborting a thread. The thread that receives the `ThreadAbortException` uses the method to cancel the abort request and continue executing. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadAbortException/Overview/threadabex.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ThreadAbEx/VB/threadabex.vb" id="Snippet1"::: - - This code produces the following output: - -``` -Thread - working. -Main - aborting my thread. -Thread - caught ThreadAbortException - resetting. -Exception message: Thread was being aborted. -Thread - still alive and working. -Thread - finished working. -Main ending. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ThreadAbEx/VB/threadabex.vb" id="Snippet1"::: + + This code produces the following output: + +``` +Thread - working. +Main - aborting my thread. +Thread - caught ThreadAbortException - resetting. +Exception message: Thread was being aborted. +Thread - still alive and working. +Thread - finished working. +Main ending. +``` + ]]> @@ -147,20 +146,19 @@ Main ending. Gets an object that contains application-specific information related to the thread abort. An object containing application-specific information. - method. The exact content and usage of this object is application defined; it is typically used to convey information that is meaningful to the thread being aborted. - - - -## Examples - The following code example shows how to pass information to a thread that is being aborted. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/CPP/source.cpp" id="Snippet1"::: + method. The exact content and usage of this object is application defined; it is typically used to convey information that is meaningful to the thread being aborted. + + + +## Examples + The following code example shows how to pass information to a thread that is being aborted. + :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Abort/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Threading/ThreadInterruptedException.xml b/xml/System.Threading/ThreadInterruptedException.xml index 31d29df4eda..9f28dc2132e 100644 --- a/xml/System.Threading/ThreadInterruptedException.xml +++ b/xml/System.Threading/ThreadInterruptedException.xml @@ -59,24 +59,23 @@ The exception that is thrown when a is interrupted while it is in a waiting state. - states until it is destroyed. Calling when a thread is in the state will cause a to be thrown in the target thread. If the thread is not in the state, the exception is not thrown until the thread enters that state. If the thread never blocks, it could complete without ever being interrupted. + + uses the HRESULT COR_E_THREADINTERRUPTED, which has the value 0x80131519. + + For a list of initial property values for an instance of , see the constructors. + + + +## Examples + The following code example shows the behavior of a running thread when it is interrupted and subsequently gets blocked. -## Remarks - After a thread is created, it is in one or more states until it is destroyed. Calling when a thread is in the state will cause a to be thrown in the target thread. If the thread is not in the state, the exception is not thrown until the thread enters that state. If the thread never blocks, it could complete without ever being interrupted. - - uses the HRESULT COR_E_THREADINTERRUPTED, which has the value 0x80131519. - - For a list of initial property values for an instance of , see the constructors. - - - -## Examples - The following code example shows the behavior of a running thread when it is interrupted and subsequently gets blocked. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Interrupt/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/VB/source.vb" id="Snippet1"::: + ]]> @@ -129,16 +128,16 @@ Initializes a new instance of the class with default properties. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The localized error message string.| - + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The localized error message string.| + ]]> Pausing and interrupting threads @@ -184,16 +183,16 @@ The error message that explains the reason for the exception. Initializes a new instance of the class with a specified error message. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The error message string.| - + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The error message string.| + ]]> Pausing and Resuming Threads @@ -254,11 +253,11 @@ The that contains contextual information about the source or destination. Initializes a new instance of the class with serialized data. - Pausing and Resuming Threads @@ -306,18 +305,18 @@ The exception that is the cause of the current exception. If the parameter is not , the current exception is raised in a block that handles the inner exception. Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. - - The following table shows the initial property values for an instance of . - -|Property|Value| -|--------------|-----------| -||The inner exception reference.| -||The error message string.| - + property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. + + The following table shows the initial property values for an instance of . + +|Property|Value| +|--------------|-----------| +||The inner exception reference.| +||The error message string.| + ]]> Pausing and Resuming Threads diff --git a/xml/System.Threading/ThreadPool.xml b/xml/System.Threading/ThreadPool.xml index 636a7ec553a..14fee295f78 100644 --- a/xml/System.Threading/ThreadPool.xml +++ b/xml/System.Threading/ThreadPool.xml @@ -108,7 +108,6 @@ ## Examples In the following example, the main application thread queues a method named `ThreadProc` to execute on a thread pool thread, sleeps for one second, and then exits. The `ThreadProc` method simply displays a message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadPool/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/VB/source.vb" id="Snippet1"::: @@ -450,7 +449,6 @@ If a thread pool implementation may have different types of work items, the coun ## Examples The following code example shows how to retrieve a count of the maximum and available number of threads in the thread pool. A work item is queued that uses `FileStream` to asynchronously write to two files. The callback methods are timed to overlap. A worker thread handles the work item and, depending on the speed and number of processors on the computer, one or two completion port threads handle the write operations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetAvailableThreads/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadPool/GetAvailableThreads/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetAvailableThreads/VB/source.vb" id="Snippet1"::: @@ -525,7 +523,6 @@ If a thread pool implementation may have different types of work items, the coun ## Examples The following example sets the minimum number of worker threads to four, and preserves the original value for the minimum number of asynchronous I/O completion threads. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetSetMinThreads/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadPool/GetMinThreads/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetSetMinThreads/VB/source.vb" id="Snippet1"::: @@ -647,7 +644,6 @@ The method overload to queue a task, which is represented by the `ThreadProc` method, to execute when a thread becomes available. No task information is supplied with this overload. Therefore, the information that is available to the `ThreadProc` method is limited to the object the method belongs to. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadPool/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/VB/source.vb" id="Snippet1"::: ]]> @@ -732,7 +728,6 @@ The following example uses the class during construction. Each object signals the provided event object when its calculation is complete, which allows the primary thread to block execution with until all five `Fibonacci` objects have calculated a result. The `Main` method then displays each `Fibonacci` result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem1/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadPool/QueueUserWorkItem/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem1/VB/source.vb" id="Snippet1"::: @@ -1208,7 +1203,6 @@ The following example uses the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a time-out occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping additional callbacks. In the case of a time-out, the task continues to wait. The `WaitProc` method ends by printing a message to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/RegisteredWaitHandle/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: @@ -1372,7 +1366,6 @@ The following example uses the delegate, see the method overload. For more information about thread creation, see [Creating Threads and Passing Data at Start Time](/dotnet/standard/threading/creating-threads-and-passing-data-at-start-time). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadStart2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadStart/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadStart2/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/ThreadStateException.xml b/xml/System.Threading/ThreadStateException.xml index 09ef9f62144..84b795296c1 100644 --- a/xml/System.Threading/ThreadStateException.xml +++ b/xml/System.Threading/ThreadStateException.xml @@ -66,32 +66,31 @@ The exception that is thrown when a is in an invalid for the method call. - states until it terminates. `ThreadStateException` is thrown by methods that cannot perform the requested operation due to the current state of a thread. For example, trying to restart an aborted thread by calling on a thread that has terminated throws a . + + uses the HRESULT COR_E_THREADSTATE, which has the value 0x80131520. + + For a list of initial property values for an instance of , see the constructors. + + + +## Examples + The following example demonstrates an error that causes the system to throw a `ThreadStateException`. -## Remarks - Once a thread is created, it is in at least one of the states until it terminates. `ThreadStateException` is thrown by methods that cannot perform the requested operation due to the current state of a thread. For example, trying to restart an aborted thread by calling on a thread that has terminated throws a . - - uses the HRESULT COR_E_THREADSTATE, which has the value 0x80131520. - - For a list of initial property values for an instance of , see the constructors. - - - -## Examples - The following example demonstrates an error that causes the system to throw a `ThreadStateException`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadStateException/Overview/threadstex.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ThreadStEx/VB/threadstex.vb" id="Snippet1"::: - - This code produces the following output: - -``` -In main. Attempting to restart myThread. - Working thread... - Caught: Thread is running or terminated. Cannot restart. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ThreadStEx/VB/threadstex.vb" id="Snippet1"::: + + This code produces the following output: + +``` +In main. Attempting to restart myThread. + Working thread... + Caught: Thread is running or terminated. Cannot restart. +``` + ]]> @@ -146,18 +145,18 @@ In main. Attempting to restart myThread. Initializes a new instance of the class with default properties. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The localized error message string.| - + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The localized error message string.| + ]]> @@ -203,18 +202,18 @@ In main. Attempting to restart myThread. The error message that explains the reason for the exception. Initializes a new instance of the class with a specified error message. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The error message string.| - + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The error message string.| + ]]> @@ -274,11 +273,11 @@ In main. Attempting to restart myThread. The that contains contextual information about the source or destination. Initializes a new instance of the class with serialized data. - XML and SOAP Serialization @@ -327,18 +326,18 @@ In main. Attempting to restart myThread. The exception that is the cause of the current exception. If the parameter is not , the current exception is raised in a block that handles the inner exception. Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. - - The following table shows the initial property values for an instance of . - -|Property|Value| -|--------------|-----------| -||The inner exception reference.| -||The error message string.| - + property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. + + The following table shows the initial property values for an instance of . + +|Property|Value| +|--------------|-----------| +||The inner exception reference.| +||The error message string.| + ]]> diff --git a/xml/System.Threading/Timeout.xml b/xml/System.Threading/Timeout.xml index 6b8772a5042..0b5ef8442ee 100644 --- a/xml/System.Threading/Timeout.xml +++ b/xml/System.Threading/Timeout.xml @@ -60,20 +60,19 @@ Contains constants that specify infinite time-out intervals. This class cannot be inherited. - is used by methods that accept an integer `millisecondsTimeout` parameter, such as , , and . is used by methods that accept a `timeout` parameter of type , such as , , and . + + + +## Examples + The following example shows a thread going to sleep for an infinite time and subsequently being woken up. -## Remarks - The members of this class are used to specify infinite time-out intervals in threading operations. is used by methods that accept an integer `millisecondsTimeout` parameter, such as , , and . is used by methods that accept a `timeout` parameter of type , such as , , and . - - - -## Examples - The following example shows a thread going to sleep for an infinite time and subsequently being woken up. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Interrupt/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/VB/source.vb" id="Snippet1"::: + ]]> This type is thread safe. @@ -124,13 +123,13 @@ A constant used to specify an infinite waiting period, for threading methods that accept an parameter. - and , this value is used to suspend the thread indefinitely. However, in most cases, we recommend that you use other classes, such as , , , or instead, to synchronize threads or manage resources. - - The value of this field is -1 (0xFFFFFFFF). - + and , this value is used to suspend the thread indefinitely. However, in most cases, we recommend that you use other classes, such as , , , or instead, to synchronize threads or manage resources. + + The value of this field is -1 (0xFFFFFFFF). + ]]> @@ -181,13 +180,13 @@ A constant used to specify an infinite waiting period, for methods that accept a parameter. - , such as and , this value is used to suspend the thread indefinitely. However, in most cases, we recommend that you use other classes, such as , , , or instead, to synchronize threads or manage resources. - - The value of this field is -00:00:00.0010000, or -1 millisecond. - + , such as and , this value is used to suspend the thread indefinitely. However, in most cases, we recommend that you use other classes, such as , , , or instead, to synchronize threads or manage resources. + + The value of this field is -00:00:00.0010000, or -1 millisecond. + ]]> diff --git a/xml/System.Threading/Timer.xml b/xml/System.Threading/Timer.xml index 6f758f56efc..aff33bbd1b8 100644 --- a/xml/System.Threading/Timer.xml +++ b/xml/System.Threading/Timer.xml @@ -314,7 +314,6 @@ The following example defines a `StatusChecker` class that includes a `CheckStat ## Examples The following code example shows how to create a `TimerCallback` delegate and initialize a new instance of the `Timer` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer/VB/source.vb" id="Snippet1"::: @@ -490,7 +489,6 @@ The following example defines a `StatusChecker` class that includes a `CheckStat ## Examples The following code example shows how to create a `TimerCallback` delegate and initialize a new instance of the `Timer` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer2/CPP/source2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer2/VB/source2.vb" id="Snippet1"::: @@ -707,7 +705,6 @@ The following example defines a `StatusChecker` class that includes a `CheckStat ## Examples The following code example demonstrates how to start a `Timer` and, after a set number of invocations, change its period. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer/VB/source.vb" id="Snippet1"::: @@ -866,7 +863,6 @@ The following example defines a `StatusChecker` class that includes a `CheckStat ## Examples The following code example demonstrates how to start a `Timer` and, after a set number of invocations, change its period. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer2/CPP/source2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer2/VB/source2.vb" id="Snippet1"::: @@ -1023,7 +1019,6 @@ The following example defines a `StatusChecker` class that includes a `CheckStat ## Examples The following code example shows how to free the resources held by a `Timer`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/TimerCallback.xml b/xml/System.Threading/TimerCallback.xml index 809649f3d3d..f22998f9673 100644 --- a/xml/System.Threading/TimerCallback.xml +++ b/xml/System.Threading/TimerCallback.xml @@ -68,25 +68,24 @@ An object containing application-specific information relevant to the method invoked by this delegate, or . Represents the method that handles calls from a . - . This method does not execute in the thread that created the timer; it executes in a separate thread pool thread that is provided by the system. The `TimerCallback` delegate invokes the method once after the start time elapses, and continues to invoke it once per timer interval until the method is called, or until the method is called with the interval value . - + . This method does not execute in the thread that created the timer; it executes in a separate thread pool thread that is provided by the system. The `TimerCallback` delegate invokes the method once after the start time elapses, and continues to invoke it once per timer interval until the method is called, or until the method is called with the interval value . + > [!NOTE] -> Callbacks can occur after the method overload has been called, because the timer queues callbacks for execution by thread pool threads. You can use the method overload to wait until all callbacks have completed. - - The timer delegate is specified when the timer is constructed, and cannot be changed. The start time for a `Timer` is passed in the `dueTime` parameter of the `Timer` constructors, and the period is passed in the `period` parameter. For an example that demonstrates creating and using a `TimerCallback` delegate, see . +> Callbacks can occur after the method overload has been called, because the timer queues callbacks for execution by thread pool threads. You can use the method overload to wait until all callbacks have completed. + + The timer delegate is specified when the timer is constructed, and cannot be changed. The start time for a `Timer` is passed in the `dueTime` parameter of the `Timer` constructors, and the period is passed in the `period` parameter. For an example that demonstrates creating and using a `TimerCallback` delegate, see . + + + +## Examples + The following code example shows how to create the delegate used with the `Timer` class. - - -## Examples - The following code example shows how to create the delegate used with the `Timer` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Threading/WaitHandle.xml b/xml/System.Threading/WaitHandle.xml index 7be7c3ff707..7081d68c011 100644 --- a/xml/System.Threading/WaitHandle.xml +++ b/xml/System.Threading/WaitHandle.xml @@ -109,7 +109,6 @@ ## Examples The following code example shows how two threads can do background tasks while the Main thread waits for the tasks to complete using the static and methods of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/WaitHandle/Overview/WaitHandle.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/WaitHandle/VB/WaitHandle.vb" id="Snippet1"::: @@ -656,7 +655,6 @@ Application code does not call this method; it is automatically invoked during g The example starts five threads, allows them to block on an created with the flag, and then releases one thread each time the user presses the ENTER key. The example then queues another five threads and releases them all using an created with the flag. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventResetMode/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: @@ -959,7 +957,6 @@ Calling `Dispose` allows the resources used by the method returns when the wait t ## Examples The following code example shows how to use the thread pool to asynchronously create and write to a group of files. Each write operation is queued as a work item and signals when it is finished. The main thread waits for all the items to signal and then exits. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll2/CPP/source2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/WaitHandle/WaitAll/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll2/VB/source2.vb" id="Snippet1"::: @@ -1347,7 +1343,6 @@ The maximum value for `timeout` is method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/WaitHandle/Overview/WaitHandle.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/WaitHandle/VB/WaitHandle.vb" id="Snippet1"::: @@ -1734,7 +1728,6 @@ The maximum number of the wait handles is 64, and 63 if the current thread is in ## Examples The following code example demonstrates how to use the thread pool to simultaneously search for a file on multiple disks. For space considerations, only the root directory of each disk is searched. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny2/CPP/source2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/WaitHandle/WaitAny/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny2/VB/source2.vb" id="Snippet1"::: @@ -1829,7 +1822,6 @@ The maximum value for `timeout` is method overload behaves when it is called within a synchronization domain. First, a thread waits with `exitContext` set to `false` and blocks until the wait timeout expires. A second thread executes after the first thread terminates and waits with `exitContext` set to `true`. The call to signal the wait handle for this second thread is not blocked, and the thread completes before the wait timeout. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.threading.waithandle.waitone4/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/WaitHandle/WaitOne/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.threading.waithandle.waitone4/vb/source.vb" id="Snippet1"::: @@ -2232,7 +2221,6 @@ The maximum value for `timeout` is if the timed out; if it was signaled. Represents a method to be called when a is signaled or times out. - represents a callback method that you want to execute when a registered wait handle times out or is signaled. Create the delegate by passing your callback method to the constructor. Your method must have the signature shown here. - - Create the registered wait handle by passing the delegate and a to . Your callback method executes each time the times out or is signaled. - - + represents a callback method that you want to execute when a registered wait handle times out or is signaled. Create the delegate by passing your callback method to the constructor. Your method must have the signature shown here. + + Create the registered wait handle by passing the delegate and a to . Your callback method executes each time the times out or is signaled. + + > [!NOTE] -> Visual Basic users can omit the constructor, and simply use the `AddressOf` operator when passing the callback method to . Visual Basic automatically calls the correct delegate constructor. - - If you want to pass information to your callback method, create an object that contains the necessary information and pass it to when you create the registered wait handle. Each time your callback method executes, the `state` parameter contains this object. - - For more information about using callback methods to synchronize thread pool threads, see [The managed thread pool](/dotnet/standard/threading/the-managed-thread-pool). - - +> Visual Basic users can omit the constructor, and simply use the `AddressOf` operator when passing the callback method to . Visual Basic automatically calls the correct delegate constructor. + + If you want to pass information to your callback method, create an object that contains the necessary information and pass it to when you create the registered wait handle. Each time your callback method executes, the `state` parameter contains this object. + + For more information about using callback methods to synchronize thread pool threads, see [The managed thread pool](/dotnet/standard/threading/the-managed-thread-pool). + + + +## Examples + The following example shows how to use the delegate to represent a callback method that is executed when a wait handle is signaled. + + The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc` and the wait handle is an . + + The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object, so that the callback method has access to the . + + In addition to the `TaskInfo` object, the call to the method specifies the the task waits on, a delegate that represents the `WaitProc` callback method, a one-second timeout interval, and multiple callbacks. + + When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a timeout occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping further callbacks. In the case of a timeout, the task continues waiting. The `WaitProc` method ends by printing a message to the console. -## Examples - The following example shows how to use the delegate to represent a callback method that is executed when a wait handle is signaled. - - The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc` and the wait handle is an . - - The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object, so that the callback method has access to the . - - In addition to the `TaskInfo` object, the call to the method specifies the the task waits on, a delegate that represents the `WaitProc` callback method, a one-second timeout interval, and multiple callbacks. - - When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a timeout occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping further callbacks. In the case of a timeout, the task continues waiting. The `WaitProc` method ends by printing a message to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/RegisteredWaitHandle/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: + ]]> Threads and Threading diff --git a/xml/System.Timers/ElapsedEventArgs.xml b/xml/System.Timers/ElapsedEventArgs.xml index 026e79a5630..202ba284e33 100644 --- a/xml/System.Timers/ElapsedEventArgs.xml +++ b/xml/System.Timers/ElapsedEventArgs.xml @@ -48,16 +48,15 @@ Provides data for the event. - object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. -## Examples - The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: + ]]> @@ -132,21 +131,20 @@ Gets the date/time when the event was raised. The time the event was raised. - event is raised on a thread, so the event-handling method might run on one thread at the same time that a call to the method runs on another thread. This might result in the event being raised after the method is called. This race condition cannot be prevented simply by comparing the property with the time when the method is called, because the event-handling method might already be executing when the method is called, or might begin executing between the moment when the method is called and the moment when the stop time is saved. If it is critical to prevent the thread that calls the method from proceeding while the event-handling method is still executing, use a more robust synchronization mechanism such as the class or the method. Code that uses the method can be found in the example for the method. - - - -## Examples - The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: + event is raised on a thread, so the event-handling method might run on one thread at the same time that a call to the method runs on another thread. This might result in the event being raised after the method is called. This race condition cannot be prevented simply by comparing the property with the time when the method is called, because the event-handling method might already be executing when the method is called, or might begin executing between the moment when the method is called and the moment when the stop time is saved. If it is critical to prevent the thread that calls the method from proceeding while the event-handling method is still executing, use a more robust synchronization mechanism such as the class or the method. Code that uses the method can be found in the example for the method. + + + +## Examples + The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. + :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Timers/ElapsedEventHandler.xml b/xml/System.Timers/ElapsedEventHandler.xml index e08a79af437..8421bfbf81e 100644 --- a/xml/System.Timers/ElapsedEventHandler.xml +++ b/xml/System.Timers/ElapsedEventHandler.xml @@ -60,21 +60,20 @@ An object that contains the event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example sets up an event handler for the event, creates a timer, and starts the timer. The event handler has the same signature as the delegate. The event handler displays the property each time it is raised. -## Remarks - When you create an delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example sets up an event handler for the event, creates a timer, and starts the timer. The event handler has the same signature as the delegate. The event handler displays the property each time it is raised. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventHandler/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventHandler/Overview/source.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Timer Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Timer Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Timers/Timer.xml b/xml/System.Timers/Timer.xml index f099995690b..93cc2e5bfe8 100644 --- a/xml/System.Timers/Timer.xml +++ b/xml/System.Timers/Timer.xml @@ -189,7 +189,6 @@ ## Examples The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: @@ -358,7 +357,6 @@ ## Examples The following example creates a whose event fires after 1.5 seconds. Its event handler then displays "Hello World!" on the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/Timer/AutoReset/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/Timer/AutoReset/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/VB/source.vb" id="Snippet1"::: @@ -589,7 +587,6 @@ ## Examples The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: @@ -680,7 +677,6 @@ ## Examples The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: @@ -841,7 +837,6 @@ ## Examples The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/ValidationEventArgs.xml b/xml/System.Xml.Schema/ValidationEventArgs.xml index 85829c5ec8e..11f40c0db17 100644 --- a/xml/System.Xml.Schema/ValidationEventArgs.xml +++ b/xml/System.Xml.Schema/ValidationEventArgs.xml @@ -54,11 +54,11 @@ Returns detailed information related to the . - method for the class. - + method for the class. + ]]> @@ -196,25 +196,24 @@ Gets the severity of the validation event. An value representing the severity of the validation event. - diff --git a/xml/System.Xml.Schema/XmlSchema.xml b/xml/System.Xml.Schema/XmlSchema.xml index 1bed338bba8..3aa973f5379 100644 --- a/xml/System.Xml.Schema/XmlSchema.xml +++ b/xml/System.Xml.Schema/XmlSchema.xml @@ -82,7 +82,6 @@ ## Examples The following example creates a schema definition. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchema Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchema/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchema Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/XmlSchemaAll.xml b/xml/System.Xml.Schema/XmlSchemaAll.xml index cb9e4d5eb96..30f830e5d48 100644 --- a/xml/System.Xml.Schema/XmlSchemaAll.xml +++ b/xml/System.Xml.Schema/XmlSchemaAll.xml @@ -50,24 +50,23 @@ Represents the World Wide Web Consortium (W3C) element (compositor). - class permits the elements in the group to appear (or not appear) in any order in the containing element. + + + +## Examples + The following example creates an `all` element. -## Remarks - The class permits the elements in the group to appear (or not appear) in any order in the containing element. - - - -## Examples - The following example creates an `all` element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaAll/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/VB/source.vb" id="Snippet1"::: - - The following XML file is generated for the preceding code example. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/VB/source.vb" id="Snippet1"::: + + The following XML file is generated for the preceding code example. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/XML/source.xml" id="Snippet2"::: + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaAnnotation.xml b/xml/System.Xml.Schema/XmlSchemaAnnotation.xml index ad7b78c5c5e..40f9c1466c8 100644 --- a/xml/System.Xml.Schema/XmlSchemaAnnotation.xml +++ b/xml/System.Xml.Schema/XmlSchemaAnnotation.xml @@ -50,26 +50,25 @@ Represents the World Wide Web Consortium (W3C) element. - instances (information for applications) and instances (comments or text for humans). + + An annotation is used to store extra information about the schema or its elements. These notes are specified for human consumption, `xs:documentation`, or by software, `xs:appinfo`. Annotation can be the first element of most schema elements or anywhere under the schema element. + + + +## Examples + The following example creates the `annotation` element. -## Remarks - An `annotation` element can contain one or more instances (information for applications) and instances (comments or text for humans). - - An annotation is used to store extra information about the schema or its elements. These notes are specified for human consumption, `xs:documentation`, or by software, `xs:appinfo`. Annotation can be the first element of most schema elements or anywhere under the schema element. - - - -## Examples - The following example creates the `annotation` element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaAnnotation/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/VB/source.vb" id="Snippet1"::: - - The following XML file is generated for the preceding code example. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/VB/source.vb" id="Snippet1"::: + + The following XML file is generated for the preceding code example. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -224,11 +223,11 @@ Gets the collection that is used to store the and child elements. An of and child elements. - (information used by applications) or (comments or text used by humans). - + (information used by applications) or (comments or text used by humans). + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaAny.xml b/xml/System.Xml.Schema/XmlSchemaAny.xml index 36ccb8acad3..a8cfc652d64 100644 --- a/xml/System.Xml.Schema/XmlSchemaAny.xml +++ b/xml/System.Xml.Schema/XmlSchemaAny.xml @@ -50,24 +50,23 @@ Represents the World Wide Web Consortium (W3C) element. - @@ -169,19 +168,19 @@ Gets or sets the namespaces containing the elements that can be used. Namespaces for elements that are available for use. The default is . Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaAnyAttribute.xml b/xml/System.Xml.Schema/XmlSchemaAnyAttribute.xml index e66f85f9ca5..468da875653 100644 --- a/xml/System.Xml.Schema/XmlSchemaAnyAttribute.xml +++ b/xml/System.Xml.Schema/XmlSchemaAnyAttribute.xml @@ -50,24 +50,23 @@ Represents the World Wide Web Consortium (W3C) element. - @@ -169,19 +168,19 @@ Gets or sets the namespaces containing the attributes that can be used. Namespaces for attributes that are available for use. The default is . Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaAppInfo.xml b/xml/System.Xml.Schema/XmlSchemaAppInfo.xml index 45d178f8da2..c9ac0401886 100644 --- a/xml/System.Xml.Schema/XmlSchemaAppInfo.xml +++ b/xml/System.Xml.Schema/XmlSchemaAppInfo.xml @@ -50,24 +50,23 @@ Represents the World Wide Web Consortium (W3C) element. - @@ -229,11 +228,11 @@ Gets or sets the source of the application information. A Uniform Resource Identifier (URI) reference. The default is . Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaAttribute.xml b/xml/System.Xml.Schema/XmlSchemaAttribute.xml index 0c9725cc01a..b9f54576717 100644 --- a/xml/System.Xml.Schema/XmlSchemaAttribute.xml +++ b/xml/System.Xml.Schema/XmlSchemaAttribute.xml @@ -50,24 +50,23 @@ Represents the element from the XML Schema as specified by the World Wide Web Consortium (W3C). Attributes provide additional information for other document elements. The attribute tag is nested between the tags of a document's element for the schema. The XML document displays attributes as named items in the opening tag of an element. - @@ -158,11 +157,11 @@ Gets an object representing the type of the attribute based on the or of the attribute. An object. - @@ -225,14 +224,14 @@ Gets the common language runtime (CLR) object based on the or of the attribute that holds the post-compilation value of the property. The common runtime library (CLR) object that holds the post-compilation value of the property. - if the attribute has a built-in XML Schema type or if the attribute has a user-defined type. This property is a post-schema-validation infoset property. - + if the attribute has a built-in XML Schema type or if the attribute has a user-defined type. This property is a post-schema-validation infoset property. + > [!IMPORTANT] -> The property is obsolete in the 2.0 version of the .NET Framework and has been replaced by the property. - +> The property is obsolete in the 2.0 version of the .NET Framework and has been replaced by the property. + ]]> @@ -295,15 +294,15 @@ Gets or sets the default value for the attribute. The default value for the attribute. The default is a null reference. Optional. - @@ -366,13 +365,13 @@ Gets or sets the fixed value for the attribute. The fixed value for the attribute. The default is null. Optional. - @@ -490,13 +489,13 @@ Gets or sets the name of the attribute. The name of the attribute. - @@ -554,11 +553,11 @@ Gets the qualified name for the attribute. The post-compilation value of the property. - @@ -616,13 +615,13 @@ Gets or sets the name of an attribute declared in this schema (or another schema indicated by the specified namespace). The name of the attribute declared. - @@ -681,11 +680,11 @@ Gets or sets the attribute type to a simple type. The simple type defined in this schema. - @@ -743,13 +742,13 @@ Gets or sets the name of the simple type defined in this schema (or another schema indicated by the specified namespace). The name of the simple type. - properties cannot be set at the same time. The type must be a QName. The type can include a namespace prefix. - - Optional. - + properties cannot be set at the same time. The type must be a QName. The type can include a namespace prefix. + + Optional. + ]]> @@ -811,18 +810,18 @@ Gets or sets information about how the attribute is used. One of the following values: None, Prohibited, Optional, or Required. The default is Optional. Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaAttributeGroup.xml b/xml/System.Xml.Schema/XmlSchemaAttributeGroup.xml index 6633b5a9aa0..239af52157d 100644 --- a/xml/System.Xml.Schema/XmlSchemaAttributeGroup.xml +++ b/xml/System.Xml.Schema/XmlSchemaAttributeGroup.xml @@ -50,24 +50,23 @@ Represents the element from the XML Schema as specified by the World Wide Web Consortium (W3C). AttributesGroups provides a mechanism to group a set of attribute declarations so that they can be incorporated as a group into complex type definitions. - @@ -278,11 +277,11 @@ Gets or sets the name of the attribute group. The name of the attribute group. - diff --git a/xml/System.Xml.Schema/XmlSchemaChoice.xml b/xml/System.Xml.Schema/XmlSchemaChoice.xml index c97aa6caeb6..48e9b3bc46f 100644 --- a/xml/System.Xml.Schema/XmlSchemaChoice.xml +++ b/xml/System.Xml.Schema/XmlSchemaChoice.xml @@ -50,19 +50,18 @@ Represents the element (compositor) from the XML Schema as specified by the World Wide Web Consortium (W3C). The allows only one of its children to appear in an instance. - diff --git a/xml/System.Xml.Schema/XmlSchemaCollection.xml b/xml/System.Xml.Schema/XmlSchemaCollection.xml index 8f412e3fdf1..c733fae27a3 100644 --- a/xml/System.Xml.Schema/XmlSchemaCollection.xml +++ b/xml/System.Xml.Schema/XmlSchemaCollection.xml @@ -92,7 +92,6 @@ ## Examples The following example validates an XML document using the `XmlSchemaCollection`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Basic/CPP/aa.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Overview/aa.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Basic/VB/aa.vb" id="Snippet1"::: @@ -616,7 +615,6 @@ schemaColl.Add("urn:author", "names.xsd"); ## Examples The following example adds a schema to the collection. An is passed to the `Add` method that sets the necessary credentials required to access any external resources referenced in the schema. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Add/CPP/schemacolladd.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Add/schemacolladd.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Add/VB/schemacolladd.vb" id="Snippet1"::: @@ -781,7 +779,6 @@ schemaColl.Add("urn:author", "names.xsd"); ## Examples The following example checks to see if a schema is in the collection. If it is, it displays the schema. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Contains/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/VB/source.vb" id="Snippet1"::: @@ -1004,7 +1001,6 @@ schemaColl.Add("urn:author", "names.xsd"); ## Examples The following example displays each of the XML Schemas in the schema collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/GetEnumerator/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/VB/source.vb" id="Snippet1"::: @@ -1075,7 +1071,6 @@ schemaColl.Add("urn:author", "names.xsd"); ## Examples The following example checks to see if a schema is in the collection. If it is, it displays the schema. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Contains/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/VB/source.vb" id="Snippet1"::: @@ -1449,7 +1444,6 @@ schemaColl.Add("urn:author", "names.xsd"); ## Examples The following example shows how to set an event handler to handle invalid XML Schemas. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchema.ValidationEventHandler/CPP/schemaevent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/ValidationEventHandler/schemaevent.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchema.ValidationEventHandler/VB/schemaevent.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/XmlSchemaCollectionEnumerator.xml b/xml/System.Xml.Schema/XmlSchemaCollectionEnumerator.xml index 1d6a94ed8dc..0f59d46291b 100644 --- a/xml/System.Xml.Schema/XmlSchemaCollectionEnumerator.xml +++ b/xml/System.Xml.Schema/XmlSchemaCollectionEnumerator.xml @@ -96,15 +96,14 @@ Gets the current in the collection. The current in the collection. - @@ -150,15 +149,14 @@ if the move was successful; if the enumerator has passed the end of the collection. - @@ -211,11 +209,11 @@ For a description of this member, see . The current node. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -263,11 +261,11 @@ For a description of this member, see . The next node. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -314,11 +312,11 @@ For a description of this member, see . - instance is cast to an interface. - + instance is cast to an interface. + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaComplexContent.xml b/xml/System.Xml.Schema/XmlSchemaComplexContent.xml index 6ee235eb17c..395065810d0 100644 --- a/xml/System.Xml.Schema/XmlSchemaComplexContent.xml +++ b/xml/System.Xml.Schema/XmlSchemaComplexContent.xml @@ -50,19 +50,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class represents the complex content model for complex types. It contains extensions or restrictions on a complex type that has either only elements or mixed content. - @@ -219,11 +218,11 @@ Gets or sets information that determines if the type has a mixed content model. If this property is , character data is allowed to appear between the child elements of the complex type (mixed content model). The default is . Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaComplexContentRestriction.xml b/xml/System.Xml.Schema/XmlSchemaComplexContentRestriction.xml index 845e205bc1c..db2f27c4f59 100644 --- a/xml/System.Xml.Schema/XmlSchemaComplexContentRestriction.xml +++ b/xml/System.Xml.Schema/XmlSchemaComplexContentRestriction.xml @@ -50,19 +50,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class is for complex types with a complex content model derived by restriction. It restricts the contents of the complex type to a subset of the inherited complex type. - @@ -272,11 +271,11 @@ Gets or sets the name of a complex type from which this type is derived by restriction. The name of the complex type from which this type is derived by restriction. - diff --git a/xml/System.Xml.Schema/XmlSchemaComplexType.xml b/xml/System.Xml.Schema/XmlSchemaComplexType.xml index d0de2b19018..92fbafa7fea 100644 --- a/xml/System.Xml.Schema/XmlSchemaComplexType.xml +++ b/xml/System.Xml.Schema/XmlSchemaComplexType.xml @@ -61,7 +61,6 @@ ## Examples The following example creates a `complexType` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaComplexType Example/CPP/complextype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaComplexType/Overview/complextype.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaComplexType Example/VB/complextype.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/XmlSchemaDatatype.xml b/xml/System.Xml.Schema/XmlSchemaDatatype.xml index 2aae8eb426f..afd49502c0f 100644 --- a/xml/System.Xml.Schema/XmlSchemaDatatype.xml +++ b/xml/System.Xml.Schema/XmlSchemaDatatype.xml @@ -55,7 +55,6 @@ ## Examples The following example shows use of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/CPP/datatype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaDatatype/Overview/datatype.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/VB/datatype.vb" id="Snippet1"::: @@ -360,7 +359,6 @@ ## Examples The following example retrieves the `LotteryNumber` simple type from the example.xsd file as an and then validates the `string` value of `5` using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/CPP/datatype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaDatatype/Overview/datatype.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/VB/datatype.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/XmlSchemaDocumentation.xml b/xml/System.Xml.Schema/XmlSchemaDocumentation.xml index a22dca1b74f..9fb60372dcc 100644 --- a/xml/System.Xml.Schema/XmlSchemaDocumentation.xml +++ b/xml/System.Xml.Schema/XmlSchemaDocumentation.xml @@ -50,24 +50,23 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class specifies information to be read or used by humans within an . - @@ -281,13 +280,13 @@ Gets or sets the Uniform Resource Identifier (URI) source of the information. A URI reference. The default is . Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaElement.xml b/xml/System.Xml.Schema/XmlSchemaElement.xml index a6879630db7..b357e2361d5 100644 --- a/xml/System.Xml.Schema/XmlSchemaElement.xml +++ b/xml/System.Xml.Schema/XmlSchemaElement.xml @@ -50,28 +50,27 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class is the base class for all particle types and is used to describe an element in an XML document. - [!IMPORTANT] > - Do not use schemas from unknown or untrusted sources or locations. Doing so will compromise the security of your code. > - XML schemas (including inline schemas) are inherently vulnerable to denial of service attacks; do not accept them in untrusted scenarios. > - Schema validation error messages and exceptions may expose sensitive information about the content model or URI paths to the schema file. Be careful not to expose this information to untrusted callers. + + + +## Examples + The following example creates the `element` element. - - -## Examples - The following example creates the `element` element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/CPP/element.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaElement/Overview/element.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/VB/element.vb" id="Snippet1"::: - - The following XML file is used for the preceding code example. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/XML/example.xsd" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/VB/element.vb" id="Snippet1"::: + + The following XML file is used for the preceding code example. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/XML/example.xsd" id="Snippet2"::: + ]]> @@ -170,22 +169,22 @@ Gets or sets a derivation. The attribute used to block a type derivation. Default value is . Optional. - @@ -239,21 +238,21 @@ Gets the post-compilation value of the property. The post-compilation value of the property. The default is the value on the element. - @@ -315,11 +314,11 @@ Gets the collection of constraints on the element. The collection of constraints. - @@ -382,11 +381,11 @@ Gets or sets the default value of the element if its content is a simple type or content of the element is . The default value for the element. The default is a null reference. Optional. - @@ -440,11 +439,11 @@ Gets an object representing the type of the element based on the or values of the element. An object. - @@ -507,16 +506,16 @@ Gets a common language runtime (CLR) object based on the or of the element, which holds the post-compilation value of the property. The common language runtime object. The post-compilation value of the property. - if the element has a built-in XML Schema type or if the element has a user-defined type. - - This property is a post-schema-validation infoset property. - + if the element has a built-in XML Schema type or if the element has a user-defined type. + + This property is a post-schema-validation infoset property. + > [!IMPORTANT] -> The property is obsolete in the 2.0 version of the .NET Framework and has been replaced by the property. - +> The property is obsolete in the 2.0 version of the .NET Framework and has been replaced by the property. + ]]> @@ -578,21 +577,21 @@ Gets or sets the property to indicate that no further derivations are allowed. The property. The default is . Optional. - . `Substitution`, `List`, and `Union` derivation methods are not allowed for this property. - + . `Substitution`, `List`, and `Union` derivation methods are not allowed for this property. + ]]> @@ -646,20 +645,20 @@ Gets the post-compilation value of the property. The post-compilation value of the property. Default value is the value on the element. - @@ -722,11 +721,11 @@ Gets or sets the fixed value. The fixed value that is predetermined and unchangeable. The default is a null reference. Optional. - @@ -788,18 +787,18 @@ Gets or sets the form for the element. The form for the element. The default is the value. Optional. - @@ -912,11 +911,11 @@ Gets or sets information that indicates if can occur in the instance data. Indicates if an explicit nil value can be assigned to the element. If nillable is , this enables an instance of the element to have the attribute set to . The attribute is defined as part of the XML Schema namespace for instances. The default is . Optional. - @@ -979,11 +978,11 @@ Gets or sets the name of the element. The name of the element. The default is . - @@ -1041,11 +1040,11 @@ Gets the actual qualified name for the given element. The qualified name of the element. The post-compilation value of the property. - is the name that a `ref` attribute refers to. The qualified name consists of the NCName of the element. For example, element name = "NCName", and the prefix used to describe the `targetNamespace` of the schema. This property holds the post-compilation value of the `QualifiedName` property. - + is the name that a `ref` attribute refers to. The qualified name consists of the NCName of the element. For example, element name = "NCName", and the prefix used to describe the `targetNamespace` of the schema. This property holds the post-compilation value of the `QualifiedName` property. + ]]> @@ -1103,13 +1102,13 @@ Gets or sets the reference name of an element declared in this schema (or another schema indicated by the specified namespace). The reference name of the element. - @@ -1172,11 +1171,11 @@ Gets or sets the type of the element. This can either be a complex type or a simple type. The type of the element. - @@ -1289,13 +1288,13 @@ Gets or sets the name of an element that is being substituted by this element. The qualified name of an element that is being substituted by this element. Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaEnumerationFacet.xml b/xml/System.Xml.Schema/XmlSchemaEnumerationFacet.xml index 1282db15532..56da6396858 100644 --- a/xml/System.Xml.Schema/XmlSchemaEnumerationFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaEnumerationFacet.xml @@ -44,19 +44,18 @@ Represents the facet from XML Schema as specified by the World Wide Web Consortium (W3C). This class specifies a list of valid values for a simpleType element. Declaration is contained within a declaration. - diff --git a/xml/System.Xml.Schema/XmlSchemaException.xml b/xml/System.Xml.Schema/XmlSchemaException.xml index cb49ed69fe4..556233328be 100644 --- a/xml/System.Xml.Schema/XmlSchemaException.xml +++ b/xml/System.Xml.Schema/XmlSchemaException.xml @@ -55,22 +55,21 @@ Returns detailed information about the schema exception. - [!IMPORTANT] -> The class may contain sensitive information that should not be exposed in untrusted scenarios. For example, the property returns the URI path to the schema file that caused the exception. The property should not be exposed in untrusted scenarios. Exceptions should be properly handled so that this sensitive information is not exposed in untrusted scenarios. - - +> The class may contain sensitive information that should not be exposed in untrusted scenarios. For example, the property returns the URI path to the schema file that caused the exception. The property should not be exposed in untrusted scenarios. Exceptions should be properly handled so that this sensitive information is not exposed in untrusted scenarios. + + + +## Examples + The following example shows the use of the `XmlSchemaException` class. -## Examples - The following example shows the use of the `XmlSchemaException` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaException Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaException/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaException Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaException Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -567,11 +566,11 @@ The that produced the . A valid object instance represents a structural validation error in the XML Schema Object Model (SOM). - @@ -622,13 +621,13 @@ Gets the Uniform Resource Identifier (URI) location of the schema that caused the exception. The URI location of the schema that caused the exception. - [!IMPORTANT] -> The property returns the URI path to the schema file that caused the exception. The property should not be exposed in untrusted scenarios. - +> The property returns the URI path to the schema file that caused the exception. The property should not be exposed in untrusted scenarios. + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaFractionDigitsFacet.xml b/xml/System.Xml.Schema/XmlSchemaFractionDigitsFacet.xml index fac6149ebfb..852b2fdf845 100644 --- a/xml/System.Xml.Schema/XmlSchemaFractionDigitsFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaFractionDigitsFacet.xml @@ -44,19 +44,18 @@ Specifies a restriction on the number of digits that can be entered for the fraction value of a simpleType element. The value of fractionDigits must be a positive integer. Represents the World Wide Web Consortium (W3C) facet. - diff --git a/xml/System.Xml.Schema/XmlSchemaGroup.xml b/xml/System.Xml.Schema/XmlSchemaGroup.xml index 3ace44e5dcf..0b50537b53e 100644 --- a/xml/System.Xml.Schema/XmlSchemaGroup.xml +++ b/xml/System.Xml.Schema/XmlSchemaGroup.xml @@ -50,19 +50,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class defines groups at the level that are referenced from the complex types. It groups a set of element declarations so that they can be incorporated as a group into complex type definitions. - @@ -158,11 +157,11 @@ Gets or sets the name of the schema group. The name of the schema group. - diff --git a/xml/System.Xml.Schema/XmlSchemaInclude.xml b/xml/System.Xml.Schema/XmlSchemaInclude.xml index ada9e6e49a5..1960add284a 100644 --- a/xml/System.Xml.Schema/XmlSchemaInclude.xml +++ b/xml/System.Xml.Schema/XmlSchemaInclude.xml @@ -50,32 +50,31 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class is used to include declarations and definitions from an external schema. The included declarations and definitions are then available for processing in the containing schema. - diff --git a/xml/System.Xml.Schema/XmlSchemaInference.xml b/xml/System.Xml.Schema/XmlSchemaInference.xml index cae81f70c65..9a6918b2737 100644 --- a/xml/System.Xml.Schema/XmlSchemaInference.xml +++ b/xml/System.Xml.Schema/XmlSchemaInference.xml @@ -43,36 +43,35 @@ Infers an XML Schema Definition Language (XSD) schema from an XML document. The class cannot be inherited. - [!IMPORTANT] -> - Do not use schemas from unknown or untrusted sources or locations. Doing so will compromise the security of your code. -> - XML schemas (including inline schemas) are inherently vulnerable to denial of service attacks; do not accept them in untrusted scenarios. -> - Schema validation error messages and exceptions may expose sensitive information about the content model or URI paths to the schema file. Be careful not to expose this information to untrusted callers. - - The class in the namespace allows you to infer an XML Schema Definition Language (XSD) schema from the structure of an XML document. The class outputs an XML schema that can validate the XML document. - - The class supports the W3C XML and XML Schemas standards. It can be used to infer a new schema or to refine an existing schema. - - - -## Examples - This example takes an XML file as input, and generates a schema that can validate the example XML. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp" id="Snippet1"::: +> - Do not use schemas from unknown or untrusted sources or locations. Doing so will compromise the security of your code. +> - XML schemas (including inline schemas) are inherently vulnerable to denial of service attacks; do not accept them in untrusted scenarios. +> - Schema validation error messages and exceptions may expose sensitive information about the content model or URI paths to the schema file. Be careful not to expose this information to untrusted callers. + + The class in the namespace allows you to infer an XML Schema Definition Language (XSD) schema from the structure of an XML document. The class outputs an XML schema that can validate the XML document. + + The class supports the W3C XML and XML Schemas standards. It can be used to infer a new schema or to refine an existing schema. + + + +## Examples + This example takes an XML file as input, and generates a schema that can validate the example XML. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaInference/Overview/XmlSchemaInferenceExamples.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet1"::: - - The following is the input XML file. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xml" id="Snippet5"::: - - The following is the schema inferred from the XML document. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xsd" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet1"::: + + The following is the input XML file. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xml" id="Snippet5"::: + + The following is the schema inferred from the XML document. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xsd" id="Snippet6"::: + ]]> @@ -165,36 +164,35 @@ Infers an XML Schema Definition Language (XSD) schema from the XML document contained in the object specified. An object containing the inferred schemas. - method infers one or more W3C XML Schema Definition Language (XSD) schemas from the XML instance document contained in the object specified. If the XML document contains elements and attributes from multiple namespaces, then multiple schemas are generated: one for each namespace used in the document. The primary schema is the schema that can validate the entire XML document, and its target namespace is the same as the namespace of the document element of the XML document. - - The following are important notes to consider when using the method. - -- The method ignores any `xsi:type`, `xsi:schemaLocation`, or `xsi:noNamespaceSchemaLocation` attributes in the XML document. - -- If the object is typed, the type information it contains is ignored. - -- If the object is positioned on an element that is not the root element of the XML document, a schema is inferred for only that element. If the object is not positioned on an element, the method is called on the parameter until an element is encountered (for example, when is ). At this point, the inference process starts from that element. If no element is encountered until the end of the document, an is thrown. - - - -## Examples - This example takes an XML file as input, and generates a schema that can validate the example XML. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp" id="Snippet1"::: + method infers one or more W3C XML Schema Definition Language (XSD) schemas from the XML instance document contained in the object specified. If the XML document contains elements and attributes from multiple namespaces, then multiple schemas are generated: one for each namespace used in the document. The primary schema is the schema that can validate the entire XML document, and its target namespace is the same as the namespace of the document element of the XML document. + + The following are important notes to consider when using the method. + +- The method ignores any `xsi:type`, `xsi:schemaLocation`, or `xsi:noNamespaceSchemaLocation` attributes in the XML document. + +- If the object is typed, the type information it contains is ignored. + +- If the object is positioned on an element that is not the root element of the XML document, a schema is inferred for only that element. If the object is not positioned on an element, the method is called on the parameter until an element is encountered (for example, when is ). At this point, the inference process starts from that element. If no element is encountered until the end of the document, an is thrown. + + + +## Examples + This example takes an XML file as input, and generates a schema that can validate the example XML. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaInference/Overview/XmlSchemaInferenceExamples.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet1"::: - - The following is the input XML file. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xml" id="Snippet5"::: - - The following is the schema inferred from the XML document. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xsd" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet1"::: + + The following is the input XML file. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xml" id="Snippet5"::: + + The following is the schema inferred from the XML document. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xsd" id="Snippet6"::: + ]]> The XML document is not well-formed. @@ -245,48 +243,47 @@ Infers an XML Schema Definition Language (XSD) schema from the XML document contained in the object specified, and refines the inferred schema using an existing schema in the object specified with the same target namespace. An object containing the inferred schemas. - method infers one or more W3C XML Schema Definition Language (XSD) schemas from the XML instance document contained in the object specified. If the XML document contains elements and attributes from multiple namespaces, multiple schemas are generated: one for each namespace used in the document. The primary schema is the schema that can validate the entire XML document, and its target namespace is the same as the namespace of the document element of the XML document. - - The following are important notes to consider when using the method. - -- The method ignores any `xsi:type`, `xsi:schemaLocation`, or `xsi:noNamespaceSchemaLocation` attributes in the XML document. - -- If the object is typed, the type information it contains is ignored. - -- If the object is positioned on an element that is not the root element of the XML document, a schema is inferred for only that element. If the object is not positioned on an element, the method is called on the parameter until an element is encountered (for example, when is ). At this point, the inference process starts from that element. If no element is encountered until the end of the document, an is thrown. - -- If an object is passed as a parameter and the element upon which the object is positioned is defined in one of the schemas in the , the inferred schema is used to refine an existing schema in the parameter with the same target namespace; otherwise, a new schema is inferred for the namespace. - - - -## Examples - The following example code takes XML document 1 as an input and generates a schema that can validate XML document 1. The example code then takes XML document 2 and refines the schema generated from XML document 1, based on the changes found in XML document 2. - - The following is XML document 1. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/item1.xml" id="Snippet13"::: - - The following is XML document 2. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/item2.xml" id="Snippet14"::: - - The following example code infers a schema from the first XML document contained in `reader`, and then refines the inferred schema with the changes found in the second XML document contained in `reader1`. The example code uses the first overloaded method to infer the schema, and the second overloaded method to refine the existing schema in the object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp" id="Snippet4"::: + method infers one or more W3C XML Schema Definition Language (XSD) schemas from the XML instance document contained in the object specified. If the XML document contains elements and attributes from multiple namespaces, multiple schemas are generated: one for each namespace used in the document. The primary schema is the schema that can validate the entire XML document, and its target namespace is the same as the namespace of the document element of the XML document. + + The following are important notes to consider when using the method. + +- The method ignores any `xsi:type`, `xsi:schemaLocation`, or `xsi:noNamespaceSchemaLocation` attributes in the XML document. + +- If the object is typed, the type information it contains is ignored. + +- If the object is positioned on an element that is not the root element of the XML document, a schema is inferred for only that element. If the object is not positioned on an element, the method is called on the parameter until an element is encountered (for example, when is ). At this point, the inference process starts from that element. If no element is encountered until the end of the document, an is thrown. + +- If an object is passed as a parameter and the element upon which the object is positioned is defined in one of the schemas in the , the inferred schema is used to refine an existing schema in the parameter with the same target namespace; otherwise, a new schema is inferred for the namespace. + + + +## Examples + The following example code takes XML document 1 as an input and generates a schema that can validate XML document 1. The example code then takes XML document 2 and refines the schema generated from XML document 1, based on the changes found in XML document 2. + + The following is XML document 1. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/item1.xml" id="Snippet13"::: + + The following is XML document 2. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/item2.xml" id="Snippet14"::: + + The following example code infers a schema from the first XML document contained in `reader`, and then refines the inferred schema with the changes found in the second XML document contained in `reader1`. The example code uses the first overloaded method to infer the schema, and the second overloaded method to refine the existing schema in the object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaInference/Overview/XmlSchemaInferenceExamples.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet4"::: - - The following schema is the schema inferred from XML document 1. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/InferSchema1.xml" id="Snippet15"::: - - The following schema is the refined version of the schema above, based on XML document 2. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/InferSchema2.xml" id="Snippet16"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet4"::: + + The following schema is the schema inferred from XML document 1. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/InferSchema1.xml" id="Snippet15"::: + + The following schema is the refined version of the schema above, based on XML document 2. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/InferSchema2.xml" id="Snippet16"::: + ]]> The XML document is not well-formed. @@ -341,36 +338,35 @@ Gets or sets the value that affects schema occurrence declarations inferred from the XML document. An object. - property is set to , the first time elements are encountered in the XML document, the schema declaration is inferred as `minOccurs="1"`. When attributes are encountered, the schema declaration is inferred as `use="required"`. - - If the property is set to , element schema declarations are inferred as `minOccurs="0"`, and attribute schema declarations are inferred as `use="optional"`. - - The default value of the property is . - - - -## Examples - This example illustrates how occurrence is affected by the property. The example code infers occurrence from an XML file in two different ways: relaxed and restricted. The following is the example XML file. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence1.xml" id="Snippet7"::: - - The following example code instructs the class to infer occurrence of elements and attributes in a relaxed way. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp" id="Snippet2"::: + property is set to , the first time elements are encountered in the XML document, the schema declaration is inferred as `minOccurs="1"`. When attributes are encountered, the schema declaration is inferred as `use="required"`. + + If the property is set to , element schema declarations are inferred as `minOccurs="0"`, and attribute schema declarations are inferred as `use="optional"`. + + The default value of the property is . + + + +## Examples + This example illustrates how occurrence is affected by the property. The example code infers occurrence from an XML file in two different ways: relaxed and restricted. The following is the example XML file. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence1.xml" id="Snippet7"::: + + The following example code instructs the class to infer occurrence of elements and attributes in a relaxed way. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaInference/Overview/XmlSchemaInferenceExamples.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet2"::: - - Because the property was set to , the following schema was generated. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence2.xml" id="Snippet8"::: - - In the example code above, if the property was not set to , the class would have defaulted to and generated the following schema. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence3.xml" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet2"::: + + Because the property was set to , the following schema was generated. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence2.xml" id="Snippet8"::: + + In the example code above, if the property was not set to , the class would have defaulted to and generated the following schema. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence3.xml" id="Snippet9"::: + ]]> @@ -423,34 +419,33 @@ Gets or sets the value that affects types inferred from the XML document. An object. - property is set to , the inferred type of elements and attributes in the XML document with simple content is always `xs:string`. If the property is set to , more specific types are inferred, such as `xs:date`, `xs:decimal`, `xs:unsignedByte`, and so on. - - The default value of the property is . - - - -## Examples - This example illustrates how type inference is affected by the property. The example code infers types from an XML file in two different ways: relaxed and restricted. The following is the example XML file. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference1.xml" id="Snippet10"::: - - The following example code instructs the class to infer `xs:string` for elements and attributes with simple content. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp" id="Snippet3"::: + property is set to , the inferred type of elements and attributes in the XML document with simple content is always `xs:string`. If the property is set to , more specific types are inferred, such as `xs:date`, `xs:decimal`, `xs:unsignedByte`, and so on. + + The default value of the property is . + + + +## Examples + This example illustrates how type inference is affected by the property. The example code infers types from an XML file in two different ways: relaxed and restricted. The following is the example XML file. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference1.xml" id="Snippet10"::: + + The following example code instructs the class to infer `xs:string` for elements and attributes with simple content. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaInference/Overview/XmlSchemaInferenceExamples.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet3"::: - - Because the property was set to , the following schema was generated. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference2.xml" id="Snippet11"::: - - In the example code above, if the property was not set to , the class would have defaulted to and generated the following schema. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference3.xml" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet3"::: + + Because the property was set to , the following schema was generated. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference2.xml" id="Snippet11"::: + + In the example code above, if the property was not set to , the class would have defaulted to and generated the following schema. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference3.xml" id="Snippet12"::: + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaKeyref.xml b/xml/System.Xml.Schema/XmlSchemaKeyref.xml index bec03633cb6..e8a07349cd8 100644 --- a/xml/System.Xml.Schema/XmlSchemaKeyref.xml +++ b/xml/System.Xml.Schema/XmlSchemaKeyref.xml @@ -50,24 +50,23 @@ This class represents the element from XMLSchema as specified by the World Wide Web Consortium (W3C). - @@ -158,11 +157,11 @@ Gets or sets the name of the key that this constraint refers to in another simple or complex type. The QName of the key that this constraint refers to. - diff --git a/xml/System.Xml.Schema/XmlSchemaLengthFacet.xml b/xml/System.Xml.Schema/XmlSchemaLengthFacet.xml index 203f7dd1d73..f2f0d3b46eb 100644 --- a/xml/System.Xml.Schema/XmlSchemaLengthFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaLengthFacet.xml @@ -44,19 +44,18 @@ Represents the facet from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the length of a element on the data type. - diff --git a/xml/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.xml b/xml/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.xml index f6b44e9f3fb..38151274f1d 100644 --- a/xml/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the maximum value of a element. The element value must be less than the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.xml b/xml/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.xml index 8be1307f374..3f92fbf8451 100644 --- a/xml/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the maximum value of a element. The element value must be less than or equal to the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaMaxLengthFacet.xml b/xml/System.Xml.Schema/XmlSchemaMaxLengthFacet.xml index 4c7ced8b3af..70db5b41572 100644 --- a/xml/System.Xml.Schema/XmlSchemaMaxLengthFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMaxLengthFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the maximum length of the data value of a element. The length must be less than the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaMinExclusiveFacet.xml b/xml/System.Xml.Schema/XmlSchemaMinExclusiveFacet.xml index 91ea6a3fde4..4b80b2a11ba 100644 --- a/xml/System.Xml.Schema/XmlSchemaMinExclusiveFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMinExclusiveFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the minimum value of a element. The element value must be greater than the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaMinInclusiveFacet.xml b/xml/System.Xml.Schema/XmlSchemaMinInclusiveFacet.xml index 67172de5e26..6afab4dcfe2 100644 --- a/xml/System.Xml.Schema/XmlSchemaMinInclusiveFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMinInclusiveFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the minimum value of a simpleType element. The element value must be greater than or equal to the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaMinLengthFacet.xml b/xml/System.Xml.Schema/XmlSchemaMinLengthFacet.xml index 624b1302934..b3ac2f1caf4 100644 --- a/xml/System.Xml.Schema/XmlSchemaMinLengthFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMinLengthFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the minimum length of the data value of a element. The length must be greater than the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaNotation.xml b/xml/System.Xml.Schema/XmlSchemaNotation.xml index ee99342a381..2e01ef0e61a 100644 --- a/xml/System.Xml.Schema/XmlSchemaNotation.xml +++ b/xml/System.Xml.Schema/XmlSchemaNotation.xml @@ -50,19 +50,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). An XML Schema declaration is a reconstruction of declarations. The purpose of notations is to describe the format of non-XML data within an XML document. - diff --git a/xml/System.Xml.Schema/XmlSchemaObject.xml b/xml/System.Xml.Schema/XmlSchemaObject.xml index fa883f92b7d..c95bc5905e3 100644 --- a/xml/System.Xml.Schema/XmlSchemaObject.xml +++ b/xml/System.Xml.Schema/XmlSchemaObject.xml @@ -50,19 +50,18 @@ Represents the root class for the Xml schema object model hierarchy and serves as a base class for classes such as the class. - @@ -108,11 +107,11 @@ Initializes a new instance of the class. - @@ -170,11 +169,11 @@ Gets or sets the line number in the file to which the element refers. The line number. - for error handling. - + for error handling. + ]]> @@ -232,11 +231,11 @@ Gets or sets the line position in the file to which the element refers. The line position. - for error handling. - + for error handling. + ]]> @@ -294,38 +293,37 @@ Gets or sets the to use with this schema object. The property for the schema object. - property to change namespace prefixes in a schema. For example, you can change the prefix used by a schema for the W3C XML Schema namespace from xs to xsd as illustrated in the following example. - -```vb -Dim namespaces As XmlSerializerNamespaces = New XmlSerializerNamespaces() -namespaces.Add("myChangedPrefix", "myImportNamespace"); -s.Namespaces = namespaces; -``` - -```csharp -XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(); -namespaces.Add("myChangedPrefix", "myImportNamespace"); -s.Namespaces = namespaces; -``` - - - -## Examples - In the following example, the prefix myImpPrefix is added at the schema element level. The prefix is then used to qualify definitions that are imported from myImportNamespace. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/CPP/namespaces.cpp" id="Snippet1"::: + property to change namespace prefixes in a schema. For example, you can change the prefix used by a schema for the W3C XML Schema namespace from xs to xsd as illustrated in the following example. + +```vb +Dim namespaces As XmlSerializerNamespaces = New XmlSerializerNamespaces() +namespaces.Add("myChangedPrefix", "myImportNamespace"); +s.Namespaces = namespaces; +``` + +```csharp +XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(); +namespaces.Add("myChangedPrefix", "myImportNamespace"); +s.Namespaces = namespaces; +``` + + + +## Examples + In the following example, the prefix myImpPrefix is added at the schema element level. The prefix is then used to qualify definitions that are imported from myImportNamespace. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaObject/Namespaces/namespaces.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/VB/namespaces.vb" id="Snippet1"::: - - The example produces the following XML. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/XML/example.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/VB/namespaces.vb" id="Snippet1"::: + + The example produces the following XML. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/XML/example.xml" id="Snippet2"::: + ]]> @@ -439,11 +437,11 @@ s.Namespaces = namespaces; Gets or sets the source location for the file that loaded the schema. The source location (URI) for the file. - diff --git a/xml/System.Xml.Schema/XmlSchemaPatternFacet.xml b/xml/System.Xml.Schema/XmlSchemaPatternFacet.xml index 9ea16e71646..b74b949f371 100644 --- a/xml/System.Xml.Schema/XmlSchemaPatternFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaPatternFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the value entered for a element. - diff --git a/xml/System.Xml.Schema/XmlSchemaSequence.xml b/xml/System.Xml.Schema/XmlSchemaSequence.xml index 27e1763caeb..55fae32d4c4 100644 --- a/xml/System.Xml.Schema/XmlSchemaSequence.xml +++ b/xml/System.Xml.Schema/XmlSchemaSequence.xml @@ -50,19 +50,18 @@ Represents the element (compositor) from the XML Schema as specified by the World Wide Web Consortium (W3C). The requires the elements in the group to appear in the specified sequence within the containing element. - diff --git a/xml/System.Xml.Schema/XmlSchemaSet.xml b/xml/System.Xml.Schema/XmlSchemaSet.xml index 3183460fe49..04de7a9187f 100644 --- a/xml/System.Xml.Schema/XmlSchemaSet.xml +++ b/xml/System.Xml.Schema/XmlSchemaSet.xml @@ -1710,7 +1710,6 @@ foreach (XmlSchema schema in schemaSet.Schemas("http://www.contoso.com/books")) ## Examples The following code example illustrates adding a to capture errors and warnings when validating an XML document against a schema. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaSetOverall Example/CPP/xmlschemasetexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlReaderSettings/Schemas/xmlschemasetexample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaSetOverall Example/VB/xmlschemasetexample.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/XmlSchemaSimpleContent.xml b/xml/System.Xml.Schema/XmlSchemaSimpleContent.xml index 88024bf014f..d82f13c7fb0 100644 --- a/xml/System.Xml.Schema/XmlSchemaSimpleContent.xml +++ b/xml/System.Xml.Schema/XmlSchemaSimpleContent.xml @@ -50,24 +50,23 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class is for simple and complex types with simple content model. - is used to indicate that the content model of the new type contains only character data and no elements. It does this through or . + + + +## Examples + The following example shows the `XmlSchemaSimpleContent` class. -## Remarks - is used to indicate that the content model of the new type contains only character data and no elements. It does this through or . - - - -## Examples - The following example shows the `XmlSchemaSimpleContent` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaSimpleContent/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/VB/source.vb" id="Snippet1"::: - - The following XML file is generated for the preceding code example. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/VB/source.vb" id="Snippet1"::: + + The following XML file is generated for the preceding code example. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -173,35 +172,35 @@ Gets one of the or . The content contained within the or class. - - - - - - - - - - - - - - - - -``` - + + + + + + + + + + + + + + + + +``` + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaSimpleType.xml b/xml/System.Xml.Schema/XmlSchemaSimpleType.xml index 00fbf4fc647..e0c3b29d311 100644 --- a/xml/System.Xml.Schema/XmlSchemaSimpleType.xml +++ b/xml/System.Xml.Schema/XmlSchemaSimpleType.xml @@ -50,24 +50,23 @@ Represents the element for simple content from XML Schema as specified by the World Wide Web Consortium (W3C). This class defines a simple type. Simple types can specify information and constraints for the value of attributes or elements with text-only content. - @@ -177,17 +176,17 @@ Gets or sets one of , , or . One of , , or . - diff --git a/xml/System.Xml.Schema/XmlSchemaSimpleTypeUnion.xml b/xml/System.Xml.Schema/XmlSchemaSimpleTypeUnion.xml index f52f45243d2..4f9aae7aea6 100644 --- a/xml/System.Xml.Schema/XmlSchemaSimpleTypeUnion.xml +++ b/xml/System.Xml.Schema/XmlSchemaSimpleTypeUnion.xml @@ -50,24 +50,23 @@ Represents the element for simple types from XML Schema as specified by the World Wide Web Consortium (W3C). A datatype can be used to specify the content of a . The value of the element must be any one of a set of alternative datatypes specified in the union. Union types are always derived types and must comprise at least two alternative datatypes. - @@ -162,11 +161,11 @@ Gets an array of objects representing the type of the element based on the and values of the simple type. An array of objects representing the type of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaUnique.xml b/xml/System.Xml.Schema/XmlSchemaUnique.xml index 2396b93d637..3bb0fc7f0b5 100644 --- a/xml/System.Xml.Schema/XmlSchemaUnique.xml +++ b/xml/System.Xml.Schema/XmlSchemaUnique.xml @@ -44,24 +44,23 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to identify a unique constraint among a set of elements. - diff --git a/xml/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.xml b/xml/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.xml index 6602203ccea..61ac0d2b648 100644 --- a/xml/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.xml @@ -44,24 +44,23 @@ Represents the World Wide Web Consortium (W3C) facet. - class defines how the simpleType value's white space will be treated. The `whiteSpace` facet value can be one of `preserve`, `replace`, or `collapse`. + + + +## Examples + The following example shows the use of the `XmlSchemaWhiteSpaceFacet` class. -## Remarks - The class defines how the simpleType value's white space will be treated. The `whiteSpace` facet value can be one of `preserve`, `replace`, or `collapse`. - - - -## Examples - The following example shows the use of the `XmlSchemaWhiteSpaceFacet` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/CPP/whitespacefacet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaWhiteSpaceFacet/Overview/whitespacefacet.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/VB/whitespacefacet.vb" id="Snippet1"::: - - The following XML file is generated for the preceding code example. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/XML/example.xsd" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/VB/whitespacefacet.vb" id="Snippet1"::: + + The following XML file is generated for the preceding code example. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/XML/example.xsd" id="Snippet2"::: + ]]> diff --git a/xml/System.Xml.Serialization/CodeGenerationOptions.xml b/xml/System.Xml.Serialization/CodeGenerationOptions.xml index 0943f5b061d..f01a4f5812b 100644 --- a/xml/System.Xml.Serialization/CodeGenerationOptions.xml +++ b/xml/System.Xml.Serialization/CodeGenerationOptions.xml @@ -52,7 +52,6 @@ object. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebServices_Description_Importer/CPP/import.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Web.Services.Description/ServiceDescriptionImporter/Overview/import.cs" id="Snippet4"::: ]]> diff --git a/xml/System.Xml.Serialization/IXmlSerializable.xml b/xml/System.Xml.Serialization/IXmlSerializable.xml index 197e4c33193..d1b6dfcaee3 100644 --- a/xml/System.Xml.Serialization/IXmlSerializable.xml +++ b/xml/System.Xml.Serialization/IXmlSerializable.xml @@ -77,7 +77,6 @@ ## Examples The following example code shows an implementation of the interface that serializes a private field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/IXmlSerializable/Overview/person.cs" id="Snippet0"::: ]]> @@ -217,12 +216,10 @@ ## Examples The following example illustrates an implementation of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/IXmlSerializable/Overview/person.cs" id="Snippet2"::: The following example illustrates the use of the class to deserialize this object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/IXmlSerializable/Overview/reader.cs" id="Snippet20"::: ]]> @@ -293,12 +290,10 @@ ## Examples The following example illustrates an implementation of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/IXmlSerializable/Overview/person.cs" id="Snippet1"::: The following example illustrates the use of the class to serialize this object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/IXmlSerializable/Overview/writer.cs" id="Snippet10"::: ]]> diff --git a/xml/System.Xml.Serialization/SoapAttributeAttribute.xml b/xml/System.Xml.Serialization/SoapAttributeAttribute.xml index 91756dadad0..7128e48e6b8 100644 --- a/xml/System.Xml.Serialization/SoapAttributeAttribute.xml +++ b/xml/System.Xml.Serialization/SoapAttributeAttribute.xml @@ -54,29 +54,28 @@ Specifies that the must serialize the class member as an encoded SOAP attribute. - class belongs to a family of attributes that controls how the serializes, or deserializes, an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. - - Apply the to a public field to specify that the serializes the field as an XML attribute. You can specify an alternative name of the attribute by setting the property. Set the if the attribute must be given a specific XML Schema definition language (XSD) data type. If the attribute belongs to a specific XML namespace, set the property. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/) - + class belongs to a family of attributes that controls how the serializes, or deserializes, an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. + + Apply the to a public field to specify that the serializes the field as an XML attribute. You can specify an alternative name of the attribute by setting the property. Set the if the attribute must be given a specific XML Schema definition language (XSD) data type. If the attribute belongs to a specific XML namespace, set the property. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/) + > [!NOTE] -> You can use the word `SoapAttribute` in your code instead of the longer . - - - -## Examples - The following example serializes a class that contains several fields to which a is applied. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp" id="Snippet1"::: +> You can use the word `SoapAttribute` in your code instead of the longer . + + + +## Examples + The following example serializes a class that contains several fields to which a is applied. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/Overview/soapattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: + ]]> @@ -135,20 +134,19 @@ Initializes a new instance of the class. - when you override the serialization of a class member. Create the , set its properties, and set the object to the property of a object. For more details, see the class overview. - - - -## Examples - The following example creates a new that is used to override the serialization of a field. After creating a and setting its properties, the object is set to the property of a . The is then added to a that is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp" id="Snippet1"::: + when you override the serialization of a class member. Create the , set its properties, and set the object to the property of a object. For more details, see the class overview. + + + +## Examples + The following example creates a new that is used to override the serialization of a field. After creating a and setting its properties, the object is set to the property of a . The is then added to a that is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/.ctor/soapattributeex2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeAttributeEx2/VB/soapattributeex2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeAttributeEx2/VB/soapattributeex2.vb" id="Snippet1"::: + ]]> @@ -205,15 +203,14 @@ The name of the XML attribute. Initializes a new instance of the class using the specified value as the name of the XML attribute. - is applied. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp" id="Snippet1"::: + is applied. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/Overview/soapattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: + ]]> @@ -263,20 +260,19 @@ Gets or sets the name of the XML attribute generated by the . The name of the XML attribute. The default is the member identifier. - property to specify an XML attribute name when the default value cannot be used. For example, if the XML attribute name is invalid as a member identifier, use a valid name for the identifier while setting the to an invalid name. - - - -## Examples - The following example serializes a class that contains several fields to which the is applied. The property is set for the `Today` field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp" id="Snippet1"::: + property to specify an XML attribute name when the default value cannot be used. For example, if the XML attribute name is invalid as a member identifier, use a valid name for the identifier while setting the to an invalid name. + + + +## Examples + The following example serializes a class that contains several fields to which the is applied. The property is set for the `Today` field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/Overview/soapattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: + ]]> @@ -326,79 +322,78 @@ Gets or sets the XML Schema definition language (XSD) data type of the SOAP attribute generated by the . An XML Schema data type. - structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema data type. Note that this does not change the serialization format, only the schema for the member. - + structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema data type. Note that this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. - +> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient then passing it as an XML attribute. - - For more information about XML Schema data types, see the World Wide Consortium document named XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - The following example serializes a class that contains several fields to which a is applied. The property is set for the `GroupNumber` and the `Today` fields. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient then passing it as an XML attribute. + + For more information about XML Schema data types, see the World Wide Consortium document named XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples + The following example serializes a class that contains several fields to which a is applied. The property is set for the `GroupNumber` and the `Today` fields. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/Overview/soapattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: + ]]> The XML Schema data type you have specified cannot be mapped to the .NET data type. @@ -458,22 +453,21 @@ Gets or sets the XML namespace of the XML attribute. The XML namespace of the XML attribute. - property conforms to the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/). - - To create namespaces that are associated with prefixes, you must create an that contains the namespaces and prefixes used in the XML document. The namespace you set for each must match one of the namespaces in the . When the generates the XML code, it correctly prefixes each attribute name. - - - -## Examples - The following example serializes a class that contains several fields to which a is applied. The property is set for the `GroupName` the field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp" id="Snippet1"::: + property conforms to the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/). + + To create namespaces that are associated with prefixes, you must create an that contains the namespaces and prefixes used in the XML document. The namespace you set for each must match one of the namespaces in the . When the generates the XML code, it correctly prefixes each attribute name. + + + +## Examples + The following example serializes a class that contains several fields to which a is applied. The property is set for the `GroupName` the field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/Overview/soapattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/SoapAttributeOverrides.xml b/xml/System.Xml.Serialization/SoapAttributeOverrides.xml index bc5e546655d..c593354fc2e 100644 --- a/xml/System.Xml.Serialization/SoapAttributeOverrides.xml +++ b/xml/System.Xml.Serialization/SoapAttributeOverrides.xml @@ -50,40 +50,39 @@ Allows you to override attributes applied to properties, fields, and classes when you use an to serialize or deserialize an object as encoded SOAP. - class enables an to override the default way of serializing a set of objects. Overriding serialization in this way has two uses: first, you can control and augment the serialization of objects found in a DLL, even if you do not have access to the source; second, you can create one set of serializable classes, but serialize the objects in multiple ways. For example, instead of serializing members of a class instance as XML elements, you can serialize them as XML attributes, resulting in a more efficient document to transport. - - After you create a , you create an using the method of the class. Pass the resulting object as an argument to the constructor. The resulting uses the data contained by the to override attributes that control how objects are serialized. To accomplish this, the contains a collection of the object types that are overridden, as well as a associated with each overridden object type. Each contains an appropriate set of attribute objects that control how each field, property, or class is serialized. - - The process for creating and using a is as follows: - -1. Create a . - -2. Create an attribute object that is appropriate to the object being overridden. For example, to override a field or property, create a , using the new, derived type. You can optionally assign a new that overrides the base class's attribute name or namespace. - -3. Add the attribute object to the appropriate property or collection. For example, you would set the property of the object to the and specify the member name that is being overridden. - -4. Create a . - -5. Add the to the using the method. If the object being overridden is a , you need only specify the type of the overridden object. But if you are overriding a field or property, you must also specify the name of the overridden member. - -6. Create an using the method of the class. - -7. When constructing the , pass the to the constructor. - -8. Use the resulting to serialize or deserialize the class objects. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + class enables an to override the default way of serializing a set of objects. Overriding serialization in this way has two uses: first, you can control and augment the serialization of objects found in a DLL, even if you do not have access to the source; second, you can create one set of serializable classes, but serialize the objects in multiple ways. For example, instead of serializing members of a class instance as XML elements, you can serialize them as XML attributes, resulting in a more efficient document to transport. + + After you create a , you create an using the method of the class. Pass the resulting object as an argument to the constructor. The resulting uses the data contained by the to override attributes that control how objects are serialized. To accomplish this, the contains a collection of the object types that are overridden, as well as a associated with each overridden object type. Each contains an appropriate set of attribute objects that control how each field, property, or class is serialized. + + The process for creating and using a is as follows: + +1. Create a . + +2. Create an attribute object that is appropriate to the object being overridden. For example, to override a field or property, create a , using the new, derived type. You can optionally assign a new that overrides the base class's attribute name or namespace. + +3. Add the attribute object to the appropriate property or collection. For example, you would set the property of the object to the and specify the member name that is being overridden. + +4. Create a . + +5. Add the to the using the method. If the object being overridden is a , you need only specify the type of the overridden object. But if you are overriding a field or property, you must also specify the name of the overridden member. + +6. Create an using the method of the class. + +7. When constructing the , pass the to the constructor. + +8. Use the resulting to serialize or deserialize the class objects. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -128,15 +127,14 @@ Initializes a new instance of the class. - is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -203,22 +201,21 @@ A that represents the overriding attributes. Adds a to a collection of objects. The parameter specifies an object to be overridden by the . - contains a union of attribute objects that cause the to override its default serialization behavior for a set of objects. You choose the attribute objects to place in the , depending on the particular behaviors you want to override. For example, the serializes a class member as an XML element by default. If you want the member to be serialized as an XML attribute instead, you would create a , assign it to the property of a , and add the to the . Use the method to add the to the . - - Use this overload to add a that contains a . Because the overrides the serialization of a class, you need not specify a member of the class to override, only the type of the class. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + contains a union of attribute objects that cause the to override its default serialization behavior for a set of objects. You choose the attribute objects to place in the , depending on the particular behaviors you want to override. For example, the serializes a class member as an XML element by default. If you want the member to be serialized as an XML attribute instead, you would create a , assign it to the property of a , and add the to the . Use the method to add the to the . + + Use this overload to add a that contains a . Because the overrides the serialization of a class, you need not specify a member of the class to override, only the type of the class. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -277,22 +274,21 @@ A that represents the overriding attributes. Adds a to the collection of objects contained by the . The parameter specifies the object to be overridden by the . The parameter specifies the name of a member that is overridden. - contains a union of attribute objects that cause the to override its default serialization behavior for a set of objects. You choose the attribute objects to place in the , depending on the particular behaviors you want to override. For example, the serializes a class member as an XML element by default. If you want the member to be serialized as a SOAP attribute instead, you would create a , assign it to the property of a , and add the to the . Use the method to add the to the . - - Use this method when the contains either a , , , or . - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + contains a union of attribute objects that cause the to override its default serialization behavior for a set of objects. You choose the attribute objects to place in the , depending on the particular behaviors you want to override. For example, the serializes a class member as an XML element by default. If you want the member to be serialized as a SOAP attribute instead, you would create a , assign it to the property of a , and add the to the . Use the method to add the to the . + + Use this method when the contains either a , , , or . + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -357,20 +353,19 @@ Gets the object associated with the specified (base class) type. A that represents the collection of overriding attributes. - that contains attributes for a . - - - -## Examples - The following example creates a that is used to override the serialization of an instance of the `Group` class. The example also uses the property to retrieve the that is used to specify how the serialization is being overridden. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp" id="Snippet1"::: + that contains attributes for a . + + + +## Examples + The following example creates a that is used to override the serialization of an instance of the `Group` class. The example also uses the property to retrieve the that is used to specify how the serialization is being overridden. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Item/attadd2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/VB/attadd2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/VB/attadd2.vb" id="Snippet1"::: + ]]> @@ -427,22 +422,21 @@ Gets the object associated with the specified (base class) type. The parameter specifies the base class member that is overridden. A that represents the collection of overriding attributes. - that contains attributes that override a , , , or . You can also return a that contains the override of a default value that uses a . - - If the contains a , you must use the overload that specifies only the overridden type. - - - -## Examples - The following example creates a used to override the serialization of an instance of the `Group` class. The example also uses the property to retrieve the that is used to specify how the serialization is being overridden. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp" id="Snippet1"::: + that contains attributes that override a , , , or . You can also return a that contains the override of a default value that uses a . + + If the contains a , you must use the overload that specifies only the overridden type. + + + +## Examples + The following example creates a used to override the serialization of an instance of the `Group` class. The example also uses the property to retrieve the that is used to specify how the serialization is being overridden. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Item/attadd.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/VB/attadd.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/VB/attadd.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/SoapAttributes.xml b/xml/System.Xml.Serialization/SoapAttributes.xml index 85c84616858..a2ed22130e9 100644 --- a/xml/System.Xml.Serialization/SoapAttributes.xml +++ b/xml/System.Xml.Serialization/SoapAttributes.xml @@ -50,24 +50,23 @@ Represents a collection of attribute objects that control how the serializes and deserializes SOAP methods. - is part of a process that overrides the default way the serializes class instances. For example, suppose you want to serialize an object that is created from a DLL that has an inaccessible source. By using the class, you can augment or otherwise control how the object is serialized. - - The members of the class correspond directly to a family of attribute classes that control serialization. For example, the property must be set to a , which allows you to override serialization of a field or property by instructing the to serialize the property value as an encoded SOAP attribute. For a complete list of attributes that control encoded SOAP serialization, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - For more details about adding an instance of the class to an instance of the class, see the class overview. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + is part of a process that overrides the default way the serializes class instances. For example, suppose you want to serialize an object that is created from a DLL that has an inaccessible source. By using the class, you can augment or otherwise control how the object is serialized. + + The members of the class correspond directly to a family of attribute classes that control serialization. For example, the property must be set to a , which allows you to override serialization of a field or property by instructing the to serialize the property value as an encoded SOAP attribute. For a complete list of attributes that control encoded SOAP serialization, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + For more details about adding an instance of the class to an instance of the class, see the class overview. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -126,20 +125,19 @@ Initializes a new instance of the class. - . Set the properties for the as appropriate to the member or object, then add the to an instance of the class. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + . Set the properties for the as appropriate to the member or object, then add the to an instance of the class. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -238,22 +236,21 @@ Gets or sets the to override. A that overrides the behavior of the when the member is serialized. - to serialize a member as an encoded SOAP XML attribute by applying a to the field or property. (The must be created with an in order to serialize an object as an encoded SOAP XML stream.) - - The property allows you to override the serialization controlled by applying a to the member. For more details on this process, see the class overview. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + to serialize a member as an encoded SOAP XML attribute by applying a to the field or property. (The must be created with an in order to serialize an object as an encoded SOAP XML stream.) + + The property allows you to override the serialization controlled by applying a to the member. For more details on this process, see the class overview. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -311,20 +308,19 @@ Gets or sets the default value of an XML element or attribute. An object that represents the default value of an XML element or attribute. - attribute to the member. If the member is being serialized as an encoded SOAP message, you can change the default value by creating a new , setting its property, and setting the property to the object. Add the to a . For more details, see the class overview. - - - -## Examples - The following example serializes a class named `Group` that includes a field named `GroupName`. The default value is set with the to ".NET". By either not setting the field, or by setting it to ".NET", the value is not serialized (because the default value is already known). The sample also overrides the default value in the `CreateOverrideSerializer` method, which is called by the `SerializeOverride` method. The example calls both methods, `SerializeOriginal` and `SerializeOverride`, and sets the same value (".NET") for the `GroupName` field. Because of the override, the value is serialized only when calling the `SerializeOverride` method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp" id="Snippet1"::: + attribute to the member. If the member is being serialized as an encoded SOAP message, you can change the default value by creating a new , setting its property, and setting the property to the object. Add the to a . For more details, see the class overview. + + + +## Examples + The following example serializes a class named `Group` that includes a field named `GroupName`. The default value is set with the to ".NET". By either not setting the field, or by setting it to ".NET", the value is not serialized (because the default value is already known). The sample also overrides the default value in the `CreateOverrideSerializer` method, which is called by the `SerializeOverride` method. The example calls both methods, `SerializeOriginal` and `SerializeOverride`, and sets the same value (".NET") for the `GroupName` field. Because of the override, the value is serialized only when calling the `SerializeOverride` method. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapDefaultValue/defvalue.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/VB/defvalue.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/VB/defvalue.vb" id="Snippet1"::: + ]]> @@ -382,22 +378,21 @@ Gets or sets a to override. The to override. - is used to control the serialization of a class member as an XML element. Set the property to a new to override the serialization of a class member as an XML element by creating a new and assigning it to the property. Then add the to a . Create an with the , then construct an with the . - - For more information, see the class overview. - - - -## Examples - The following example serializes a class named `Transportation`. The serialization of the `Vehicle` field is overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: + is used to control the serialization of a class member as an XML element. Set the property to a new to override the serialization of a class member as an XML element by creating a new and assigning it to the property. Then add the to a . Create an with the , then construct an with the . + + For more information, see the class overview. + + + +## Examples + The following example serializes a class named `Transportation`. The serialization of the `Vehicle` field is overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -455,22 +450,21 @@ Gets or sets an object that specifies how the serializes a SOAP enumeration. An object that specifies how the serializes an enumeration member. - is used to control the serialization of an enumeration member. Set the property to a new to override the serialization of such a member. - - For more information, see the class overview. - - - -## Examples - The following example serializes two classes named `Food` and `FoodType`. The `FoodType` class contains two enumerations that are overridden, and for each enumeration, the example creates a that it assigns to the property of a . The example then adds the to a , which is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp" id="Snippet1"::: + is used to control the serialization of an enumeration member. Set the property to a new to override the serialization of such a member. + + For more information, see the class overview. + + + +## Examples + The following example serializes two classes named `Food` and `FoodType`. The `FoodType` class contains two enumerations that are overridden, and for each enumeration, the example creates a that it assigns to the property of a . The example then adds the to a , which is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapEnum/soapenumoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: + ]]> @@ -528,24 +522,23 @@ if the must not serialize the field or property; otherwise, . - . That is, the value of each public field or property is persisted as an XML element or XML attribute in an XML document. - - To override the default serialization of a field or property, create a , and set its property to `true`. Use the method to add the object to a and specify the type of the object that contains the field or property to ignore and the name of the field or property to ignore. - - If a is applied to a field or property, the field or property is ignored. However you can override that behavior by creating a , setting its property to `false`, and adding it to a , specifying the type of the object that contains the field or property and the name of the field or property. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + . That is, the value of each public field or property is persisted as an XML element or XML attribute in an XML document. + + To override the default serialization of a field or property, create a , and set its property to `true`. Use the method to add the object to a and specify the type of the object that contains the field or property to ignore and the name of the field or property to ignore. + + If a is applied to a field or property, the field or property is ignored. However you can override that behavior by creating a , setting its property to `false`, and adding it to a , specifying the type of the object that contains the field or property and the name of the field or property. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -603,20 +596,19 @@ Gets or sets an object that instructs the how to serialize an object type into encoded SOAP XML. A that either overrides a applied to a class declaration, or is applied to a class declaration. - can be used to control the XML stream generated by the . Set the property to a new to control the schema for the XML that is generated when a class is serialized. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + can be used to control the XML stream generated by the . Set the property to a new to control the schema for the XML that is generated when a class is serialized. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/SoapElementAttribute.xml b/xml/System.Xml.Serialization/SoapElementAttribute.xml index 686751ef3b6..29f301acbaa 100644 --- a/xml/System.Xml.Serialization/SoapElementAttribute.xml +++ b/xml/System.Xml.Serialization/SoapElementAttribute.xml @@ -54,26 +54,25 @@ Specifies that the public member value be serialized by the as an encoded SOAP XML element. - class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. - - Apply the to a public field to direct the to serialize the field as an encoded SOAP XML element. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: + class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. + + Apply the to a public field to direct the to serialize the field as an encoded SOAP XML element. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + + + +## Examples + The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -129,15 +128,14 @@ Initializes a new instance of the class. - is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: + is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -188,15 +186,14 @@ The XML element name of the serialized member. Initializes a new instance of the class and specifies the name of the XML element. - is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: + is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -246,79 +243,78 @@ Gets or sets the XML Schema definition language (XSD) data type of the generated XML element. One of the XML Schema data types. - structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema type. Note that this does not change the serialization format, only the schema for the member. - + structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema type. Note that this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. - +> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient than passing it as an XML attribute. - - For more information about XML data types, see the World Wide Web Consortium document, [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient than passing it as an XML attribute. + + For more information about XML data types, see the World Wide Web Consortium document, [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples + The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -368,15 +364,14 @@ Gets or sets the name of the generated XML element. The name of the generated XML element. The default is the member identifier. - is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: + is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -431,22 +426,22 @@ if the generates the attribute; otherwise, . - property is set to `true`, the `xsi:null` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. - -``` - -``` - - If the property is `false`, no XML element is generated. - + property is set to `true`, the `xsi:null` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. + +``` + +``` + + If the property is `false`, no XML element is generated. + > [!NOTE] -> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. - +> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. + ]]> diff --git a/xml/System.Xml.Serialization/SoapEnumAttribute.xml b/xml/System.Xml.Serialization/SoapEnumAttribute.xml index 525d8345981..055a916b098 100644 --- a/xml/System.Xml.Serialization/SoapEnumAttribute.xml +++ b/xml/System.Xml.Serialization/SoapEnumAttribute.xml @@ -54,33 +54,32 @@ Controls how the serializes an enumeration member. - class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. - - Use the to change the enumeration that the generates or recognizes (when it serializes or deserializes a class, respectively). For example, if an enumeration contains a member named `One`, but you prefer that the XML output be named `Single`, apply the to the enumeration member and set the property to "Single". - - You can override the property value of a by creating an instance of the class and assigning it to the property of a . For details, see the class overview. - - To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. - + class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. + + Use the to change the enumeration that the generates or recognizes (when it serializes or deserializes a class, respectively). For example, if an enumeration contains a member named `One`, but you prefer that the XML output be named `Single`, apply the to the enumeration member and set the property to "Single". + + You can override the property value of a by creating an instance of the class and assigning it to the property of a . For details, see the class overview. + + To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. + > [!NOTE] -> You can use the word `SoapEnum` in your code instead of the longer . - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp" id="Snippet1"::: +> You can use the word `SoapEnum` in your code instead of the longer . + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + + + +## Examples + The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapEnum/soapenumoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: + ]]> @@ -136,23 +135,22 @@ Initializes a new instance of the class. - to override an existing enumeration. Create a new , set its properties and assign the object to the property of a . For each member of the enumeration, you must create a new and add it to the . For more details, see the class overview. - + to override an existing enumeration. Create a new , set its properties and assign the object to the property of a . For each member of the enumeration, you must create a new and add it to the . For more details, see the class overview. + > [!NOTE] -> You can use the word `SoapEnum` in your code instead of the longer . - - - -## Examples - The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp" id="Snippet1"::: +> You can use the word `SoapEnum` in your code instead of the longer . + + + +## Examples + The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapEnum/soapenumoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: + ]]> @@ -202,23 +200,22 @@ The XML element name generated by the . Initializes a new instance of the class using the specified element name. - when you want the generated XML enumerator to differ from the enumerator found in the enumeration. - + when you want the generated XML enumerator to differ from the enumerator found in the enumeration. + > [!NOTE] -> You can use the word `SoapEnum` in your code instead of the longer . - - - -## Examples - The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp" id="Snippet1"::: +> You can use the word `SoapEnum` in your code instead of the longer . + + + +## Examples + The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapEnum/soapenumoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: + ]]> @@ -268,23 +265,22 @@ Gets or sets the value generated in an XML document when the serializes an enumeration, or the value recognized when it deserializes the enumeration member. The value generated in an XML document when the serializes the enumeration, or the value recognized when it deserializes the enumeration member. - when you want the generated XML enumerator to differ from the enumerator found in the enumeration. - + when you want the generated XML enumerator to differ from the enumerator found in the enumeration. + > [!NOTE] -> You can use the word `SoapEnum` instead of the longer . - - - -## Examples - The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp" id="Snippet1"::: +> You can use the word `SoapEnum` instead of the longer . + + + +## Examples + The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapEnum/soapenumoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/SoapIgnoreAttribute.xml b/xml/System.Xml.Serialization/SoapIgnoreAttribute.xml index 407ab95442d..2fb512e8774 100644 --- a/xml/System.Xml.Serialization/SoapIgnoreAttribute.xml +++ b/xml/System.Xml.Serialization/SoapIgnoreAttribute.xml @@ -50,29 +50,28 @@ Instructs the not to serialize the public field or public read/write property value. - class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. - - Apply the to any class member that you want the to ignore when an instance of the class is serialized. For example, you may do this when the member is used to contain metadata about the object being serialized. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. + + Apply the to any class member that you want the to ignore when an instance of the class is serialized. For example, you may do this when the member is used to contain metadata about the object being serialized. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `SoapIgnore` in your code instead of the longer . - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: +> You can use the word `SoapIgnore` in your code instead of the longer . + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -118,15 +117,14 @@ Initializes a new instance of the class. - is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/SoapReflectionImporter.xml b/xml/System.Xml.Serialization/SoapReflectionImporter.xml index f26d87c315d..65d79d98d64 100644 --- a/xml/System.Xml.Serialization/SoapReflectionImporter.xml +++ b/xml/System.Xml.Serialization/SoapReflectionImporter.xml @@ -50,20 +50,19 @@ Generates mappings to SOAP-encoded messages from .NET types or Web service method information. - class provides type mappings to SOAP-encoded message parts, as defined in a Web Services Description Language (WSDL) document. It is used only when a Web service or client specifies SOAP encoding, as described in Section 5 of the SOAP 1.1 specification. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + class provides type mappings to SOAP-encoded message parts, as defined in a Web Services Description Language (WSDL) document. It is used only when a Web service or client specifies SOAP encoding, as described in Section 5 of the SOAP 1.1 specification. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -345,21 +344,21 @@ Generates internal type mappings for information that is gathered from a Web service method. Internal .NET type mappings to the element parts of a WSDL message definition. - method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. - - The following list describes possible values for the `members` parameter: - -- Web service method input parameters. - -- Web service method output parameters, plus the return type, if not void, at index zero. - -- SOAP input headers. - -- SOAP output headers. - + method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. + + The following list describes possible values for the `members` parameter: + +- Web service method input parameters. + +- Web service method output parameters, plus the return type, if not void, at index zero. + +- SOAP input headers. + +- SOAP output headers. + ]]> @@ -442,21 +441,21 @@ Generates internal type mappings for information that is gathered from a Web service method. Internal .NET type mappings to the element parts of a WSDL message definition. - method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. - - The following list describes possible values for the `members` parameter: - -- Web service method input parameters. - -- Web service method output parameters, plus the return type, if not void, at index zero. - -- SOAP input headers. - -- SOAP output headers. - + method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. + + The following list describes possible values for the `members` parameter: + +- Web service method input parameters. + +- Web service method output parameters, plus the return type, if not void, at index zero. + +- SOAP input headers. + +- SOAP output headers. + ]]> @@ -542,21 +541,21 @@ Generates internal type mappings for information that is gathered from a Web service method. Internal .NET type mappings to the element parts of a WSDL message definition. - method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. - - The following list describes possible values for the `members` parameter: - -- Web service method input parameters. - -- Web service method output parameters, plus the return type, if not void, at index zero. - -- SOAP input headers. - -- SOAP output headers. - + method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. + + The following list describes possible values for the `members` parameter: + +- Web service method input parameters. + +- Web service method output parameters, plus the return type, if not void, at index zero. + +- SOAP input headers. + +- SOAP output headers. + ]]> @@ -639,21 +638,21 @@ Generates internal type mappings for information that is gathered from a Web service method. Internal .NET type mappings to the element parts of a WSDL message definition. - method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. - - The following list describes possible values for the `members` parameter: - -- Web service method input parameters. - -- Web service method output parameters, plus the return type, if not void, at index zero. - -- SOAP input headers. - -- SOAP output headers. - + method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. + + The following list describes possible values for the `members` parameter: + +- Web service method input parameters. + +- Web service method output parameters, plus the return type, if not void, at index zero. + +- SOAP input headers. + +- SOAP output headers. + ]]> @@ -721,13 +720,13 @@ Generates a mapping to an XML Schema element for a .NET type. Internal .NET mapping of a type to an XML Schema element. - method directly. - + method directly. + ]]> @@ -791,13 +790,13 @@ Generates a mapping to an XML Schema element for a .NET type. Internal .NET mapping of a type to an XML Schema element. - method directly. - + method directly. + ]]> @@ -850,11 +849,11 @@ The .NET type for which to save type mapping information. Places mappings for a type in the instance's context for later use when import methods are invoked. - method directly. - + method directly. + ]]> diff --git a/xml/System.Xml.Serialization/SoapTypeAttribute.xml b/xml/System.Xml.Serialization/SoapTypeAttribute.xml index 600bb49a345..628f3c51f6a 100644 --- a/xml/System.Xml.Serialization/SoapTypeAttribute.xml +++ b/xml/System.Xml.Serialization/SoapTypeAttribute.xml @@ -54,28 +54,27 @@ Controls the schema generated by the when a class instance is serialized as SOAP encoded XML. - class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - To serialize an object as an encoded SOAP message, construct the using an created with the method of the class. - - The can only be applied to class declarations. - - The property determines whether the resulting XML element type is included in the XML Schema document (.xsd) for the generated XML stream. To see the schema, compile the class into a DLL file. Pass the resulting file as an argument to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool generates the XML Schema for the XML stream generated when the class is serialized by an instance of the class. - - Setting a different namespace causes Xsd.exe to write a different schema (.xsd) file for the XML stream generated when the class is serialized. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class, with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + To serialize an object as an encoded SOAP message, construct the using an created with the method of the class. + + The can only be applied to class declarations. + + The property determines whether the resulting XML element type is included in the XML Schema document (.xsd) for the generated XML stream. To see the schema, compile the class into a DLL file. Pass the resulting file as an argument to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool generates the XML Schema for the XML stream generated when the class is serialized by an instance of the class. + + Setting a different namespace causes Xsd.exe to write a different schema (.xsd) file for the XML stream generated when the class is serialized. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class, with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -125,20 +124,19 @@ Initializes a new instance of the class. - when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details about overriding SOAP serialization. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details about overriding SOAP serialization. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -183,20 +181,19 @@ The name of the XML type that the generates when it serializes the class instance (and recognizes when it deserializes the class instance). Initializes a new instance of the class and specifies the name of the XML type. - when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details about overriding SOAP serialization. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details about overriding SOAP serialization. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -243,22 +240,21 @@ The XML namespace of the type. Initializes a new instance of the class and specifies the name and XML namespace of the type. - when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details on overriding SOAP serialization. - - If you set a value for more than one type (that is, if you apply the attribute to more than one class with a different value for each one), the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) generates a separate schema file (.xsd) for each type. This is because setting a different namespace for each type renders each type distinct from the others, which makes it necessary for each type to be written out as an independent entity. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details on overriding SOAP serialization. + + If you set a value for more than one type (that is, if you apply the attribute to more than one class with a different value for each one), the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) generates a separate schema file (.xsd) for each type. This is because setting a different namespace for each type renders each type distinct from the others, which makes it necessary for each type to be written out as an independent entity. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -313,20 +309,19 @@ to include the type in SOAP-encoded XML Schema documents; otherwise, . The default is . - to a class declaration to specify whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition of the XML stream generated when the class is serialized. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + to a class declaration to specify whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition of the XML stream generated when the class is serialized. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -381,20 +376,19 @@ Gets or sets the namespace of the XML type. The namespace of the XML type. The default is an empty string (""). - value for more than one type (that is, if you apply the attribute to more than one class with a different value for each one), the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) generates a separate schema file (.xsd) for each type. This is because setting a different namespace for each type renders each type distinct from the others, which makes it necessary for each type to be written out as an independent entity. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + value for more than one type (that is, if you apply the attribute to more than one class with a different value for each one), the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) generates a separate schema file (.xsd) for each type. This is because setting a different namespace for each type renders each type distinct from the others, which makes it necessary for each type to be written out as an independent entity. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -448,20 +442,19 @@ Gets or sets the name of the XML type. The name of the XML type. The default is the class name. - to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML Schema document. To see the results of setting the object's properties, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML Schema document. To see the results of setting the object's properties, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/UnreferencedObjectEventArgs.xml b/xml/System.Xml.Serialization/UnreferencedObjectEventArgs.xml index 3b4fd26282a..dce71fba80c 100644 --- a/xml/System.Xml.Serialization/UnreferencedObjectEventArgs.xml +++ b/xml/System.Xml.Serialization/UnreferencedObjectEventArgs.xml @@ -59,8 +59,6 @@ For more information about handling events, see [Events Overview](/dotnet/desktop/winforms/events-overview-windows-forms) - - ## Examples The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. @@ -77,7 +75,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: @@ -151,7 +148,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: @@ -230,7 +226,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: @@ -309,7 +304,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/UnreferencedObjectEventHandler.xml b/xml/System.Xml.Serialization/UnreferencedObjectEventHandler.xml index d2a0d08ac82..f05d8e09765 100644 --- a/xml/System.Xml.Serialization/UnreferencedObjectEventHandler.xml +++ b/xml/System.Xml.Serialization/UnreferencedObjectEventHandler.xml @@ -60,35 +60,34 @@ An that contains the event data. Represents the method that handles the event of an . - delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/) - - The event occurs only when you call the method. - - - -## Examples - The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. - -``` - - - - - ABCD - - - 1234 - - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: + delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/) + + The event occurs only when you call the method. + + + +## Examples + The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. + +``` + + + + + ABCD + + + 1234 + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlAnyAttributeAttribute.xml b/xml/System.Xml.Serialization/XmlAnyAttributeAttribute.xml index 11eb0697484..f5ccac4ee90 100644 --- a/xml/System.Xml.Serialization/XmlAnyAttributeAttribute.xml +++ b/xml/System.Xml.Serialization/XmlAnyAttributeAttribute.xml @@ -73,38 +73,37 @@ Specifies that the member (a field that returns an array of objects) can contain any XML attributes. - to contain arbitrary data (as XML attributes) that is sent as part of an XML document, such as, metadata sent as part of the document. - - Apply the to a field that returns an array of or objects. When the method of the class is called, all XML attributes that do not have a corresponding member in the class being deserialized are collected in the array. After deserialization, you can iterate through the collection of items to process the data. - - The and events of the do not occur if you apply the to a member of a class. - + to contain arbitrary data (as XML attributes) that is sent as part of an XML document, such as, metadata sent as part of the document. + + Apply the to a field that returns an array of or objects. When the method of the class is called, all XML attributes that do not have a corresponding member in the class being deserialized are collected in the array. After deserialization, you can iterate through the collection of items to process the data. + + The and events of the do not occur if you apply the to a member of a class. + > [!NOTE] -> You can use the word `XmlAnyAttribute` in your code instead of the longer . - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example collects all unknown attributes into an array of objects. To try the example, create a file named `UnknownAttributes.xml` that contains the following XML: - -``` - - - MyGroup - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlAnyAttribute` in your code instead of the longer . + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + + + +## Examples + The following example collects all unknown attributes into an array of objects. To try the example, create a file named `UnknownAttributes.xml` that contains the following XML: + +``` + + + MyGroup + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyAttributeAttribute/Overview/anyattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/VB/anyattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/VB/anyattribute.vb" id="Snippet1"::: + ]]> @@ -165,22 +164,21 @@ GroupType = 'Technical' GroupNumber = '42' GroupBase = 'Red'> Constructs a new instance of the class. - that is used to override the deserialization of an object. To try the example, create a file named UnknownAttributes.xml that contains the following XML: - -``` - - - MyGroup - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp" id="Snippet1"::: + that is used to override the deserialization of an object. To try the example, create a file named UnknownAttributes.xml that contains the following XML: + +``` + + + MyGroup + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyAttributeAttribute/.ctor/anyattover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/VB/anyattover.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/VB/anyattover.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlAnyElementAttribute.xml b/xml/System.Xml.Serialization/XmlAnyElementAttribute.xml index 076de633d20..d0c2fe370cb 100644 --- a/xml/System.Xml.Serialization/XmlAnyElementAttribute.xml +++ b/xml/System.Xml.Serialization/XmlAnyElementAttribute.xml @@ -73,39 +73,38 @@ Specifies that the member (a field that returns an array of or objects) contains objects that represent any XML element that has no corresponding member in the object being serialized or deserialized. - [!TIP] -> When working in a portable class library, such as in Silverlight, Windows Phone or Windows Store App project, and you are using the .NET Framework 4.0.3 and above, use or in place of and . - - Use the to contain arbitrary data (as XML elements) that can be sent as part of an XML document, such as metadata sent as part of the document. - - Apply the to a field that returns an array of or objects. Such a field can be used in two ways, depending on whether an object is being serialized or deserialized. When serialized, the object is generated as XML elements or nodes, even though they have no corresponding member (or members) in the object being serialized. If you specify a property value when applying the attribute, all or objects inserted into the array must have the same element name and default namespace, or an exception is thrown. If you set the property value, you must set the property as well, and the or objects must also have the same name and namespace values. If no value is specified, the or objects can have any element name. - - When you call the method of the class, all elements that do not have a corresponding member in the object being deserialized are collected in the array. After deserialization, iterate through the collection of items to process the data. If you specify a value, the array contains only XML elements with that name. If you do not specify a value, the array contains all elements that have no corresponding member in the class. If a class contains more than one field to which the attribute is applied, use the , or and properties to differentiate between the contents of the arrays. If such a class (with multiple fields) also contains one field that has no differentiating property values set (in other words, and ) during deserialization, this array contains any unknown XML elements that are not already contained in the other arrays. If a class contains more than one field that does not have a differentiating , or and value set, the behavior during deserialization is unspecified. - - You can also apply the to a field that returns a single object. If you do so, you must use the properties and methods of the class to recursively iterate through the unknown elements. - - You can apply multiple instances of the to a class member, but each instance must have a distinct property value. Or, if the same property is set for each instance, a distinct property value must be set for each instance. - - The and events of the do not occur if you apply the to a member of a class. - +> When working in a portable class library, such as in Silverlight, Windows Phone or Windows Store App project, and you are using the .NET Framework 4.0.3 and above, use or in place of and . + + Use the to contain arbitrary data (as XML elements) that can be sent as part of an XML document, such as metadata sent as part of the document. + + Apply the to a field that returns an array of or objects. Such a field can be used in two ways, depending on whether an object is being serialized or deserialized. When serialized, the object is generated as XML elements or nodes, even though they have no corresponding member (or members) in the object being serialized. If you specify a property value when applying the attribute, all or objects inserted into the array must have the same element name and default namespace, or an exception is thrown. If you set the property value, you must set the property as well, and the or objects must also have the same name and namespace values. If no value is specified, the or objects can have any element name. + + When you call the method of the class, all elements that do not have a corresponding member in the object being deserialized are collected in the array. After deserialization, iterate through the collection of items to process the data. If you specify a value, the array contains only XML elements with that name. If you do not specify a value, the array contains all elements that have no corresponding member in the class. If a class contains more than one field to which the attribute is applied, use the , or and properties to differentiate between the contents of the arrays. If such a class (with multiple fields) also contains one field that has no differentiating property values set (in other words, and ) during deserialization, this array contains any unknown XML elements that are not already contained in the other arrays. If a class contains more than one field that does not have a differentiating , or and value set, the behavior during deserialization is unspecified. + + You can also apply the to a field that returns a single object. If you do so, you must use the properties and methods of the class to recursively iterate through the unknown elements. + + You can apply multiple instances of the to a class member, but each instance must have a distinct property value. Or, if the same property is set for each instance, a distinct property value must be set for each instance. + + The and events of the do not occur if you apply the to a member of a class. + > [!NOTE] -> You can use the word `XmlAnyElement` in your code instead of the longer . - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example applies the to a field named `AllElements` that returns an array of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlAnyElement` in your code instead of the longer . + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + + + +## Examples + The following example applies the to a field named `AllElements` that returns an array of objects. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -163,11 +162,11 @@ Initializes a new instance of the class. - constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. - + constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. + ]]> @@ -219,11 +218,11 @@ The name of the XML element that the generates. Initializes a new instance of the class and specifies the XML element name generated in the XML document. - constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. - + constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. + ]]> @@ -277,11 +276,11 @@ The XML namespace of the XML element. Initializes a new instance of the class and specifies the XML element name generated in the XML document and its XML namespace. - constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. - + constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. + ]]> @@ -342,22 +341,21 @@ Gets or sets the XML element name. The name of the XML element. - property value when applying the attribute, all or objects inserted into the array must have the same element name and default namespace, or an exception is thrown. If you set the property value, you must set the property as well, and the or objects must also have the same name and namespace values. If no value is specified, the or objects can have any element name. - - When you call the method of the class, all attributes that do not have a corresponding member in the object being deserialized are collected in the array. If you specify a value, the array contains only XML elements with that name. If you do not specify a value, the array contains all elements that have no corresponding member in the class. If a class contains more than one field to which the attribute is applied, use the and properties to differentiate between the contents of the arrays. If such a class (with multiple fields) also contains one field that has no differentiating property values set (that is, and ) during deserialization, the array contains any XML elements that are not already contained in the other arrays. If you add more than one field that does not have a differentiating or value set, the last field in the class contains all unknown elements that are not already contained in the other arrays, and any other fields are set to `null`. - - You can apply multiple instances of the to a class member, but each instance must have a distinct property value. Or, if the same property is set for each instance, a distinct property value must be set for each instance. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp" id="Snippet1"::: + property value when applying the attribute, all or objects inserted into the array must have the same element name and default namespace, or an exception is thrown. If you set the property value, you must set the property as well, and the or objects must also have the same name and namespace values. If no value is specified, the or objects can have any element name. + + When you call the method of the class, all attributes that do not have a corresponding member in the object being deserialized are collected in the array. If you specify a value, the array contains only XML elements with that name. If you do not specify a value, the array contains all elements that have no corresponding member in the class. If a class contains more than one field to which the attribute is applied, use the and properties to differentiate between the contents of the arrays. If such a class (with multiple fields) also contains one field that has no differentiating property values set (that is, and ) during deserialization, the array contains any XML elements that are not already contained in the other arrays. If you add more than one field that does not have a differentiating or value set, the last field in the class contains all unknown elements that are not already contained in the other arrays, and any other fields are set to `null`. + + You can apply multiple instances of the to a class member, but each instance must have a distinct property value. Or, if the same property is set for each instance, a distinct property value must be set for each instance. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttribute/Name/anyelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyElementAttribute Example/VB/anyelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyElementAttribute Example/VB/anyelement.vb" id="Snippet1"::: + ]]> The element name of an array member does not match the element name specified by the property. @@ -416,20 +414,19 @@ Gets or sets the XML namespace generated in the XML document. An XML namespace. - property allows you to set a unique name for the XML attribute. The property conforms to the rules for creating an XML namespace as found in the [Namespaces in XML](https://www.w3.org/TR/xml-names/) document from the World Wide Web Consortium. - - To set the property to a prefixed name, create an that contains the namespaces and prefixes used in the XML document. Set the property to one of the namespaces in the . When the XML is generated, the attribute name is correctly prefixed with the prefix associated with the specified namespace. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp" id="Snippet1"::: + + To set the property to a prefixed name, create an that contains the namespaces and prefixes used in the XML document. Set the property to one of the namespaces in the . When the XML is generated, the attribute name is correctly prefixed with the prefix associated with the specified namespace. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttribute/Name/anyelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyElementAttribute Example/VB/anyelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyElementAttribute Example/VB/anyelement.vb" id="Snippet1"::: + ]]> @@ -485,14 +482,14 @@ Gets or sets the explicit order in which the elements are serialized or deserialized. The order of the code generation. - enumeration to instruct the to generate code that sets the property. - + enumeration to instruct the to generate code that sets the property. + > [!IMPORTANT] -> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. - +> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. + ]]> diff --git a/xml/System.Xml.Serialization/XmlAnyElementAttributes.xml b/xml/System.Xml.Serialization/XmlAnyElementAttributes.xml index 09668bfef24..36b2b3f3f9a 100644 --- a/xml/System.Xml.Serialization/XmlAnyElementAttributes.xml +++ b/xml/System.Xml.Serialization/XmlAnyElementAttributes.xml @@ -101,7 +101,6 @@ ## Examples The following example creates a new and adds it to the collection of objects accessed through the property. The is then added to a , which is used to create an . The is used to serialize or deserialize an object. To see the effect of using the property, create an XML document named UnknownElements.xml by running the `SerializeObject` method in the `Main` method. Edit the resulting document to include other (unknown) elements. Comment out the `SerializeObject` call in the `Main` method, and uncomment the call to the `DeserializeObject` method, which prints out the name and value of any unknown XML element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttributes/Overview/xmlanyover.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/VB/xmlanyover.vb" id="Snippet1"::: @@ -209,7 +208,6 @@ ## Examples The following example creates a new and adds it to the collection of objects accessed through the property. The is then added to an , which is used to create an . The is used to serialize or deserialize an object. To see the effect of using the property, create an XML document named UnknownElements.xml by running the `SerializeObject` method in the `Main` method. Edit the resulting document to include other (unknown) elements. Comment out the `SerializeObject` call in the `Main` method, and uncomment the call to the `DeserializeObject` method, which prints out the name and value of any unknown XML element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttributes/Overview/xmlanyover.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/VB/xmlanyover.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/XmlArrayAttribute.xml b/xml/System.Xml.Serialization/XmlArrayAttribute.xml index 2a73f02e4fe..8b7b007563f 100644 --- a/xml/System.Xml.Serialization/XmlArrayAttribute.xml +++ b/xml/System.Xml.Serialization/XmlArrayAttribute.xml @@ -61,33 +61,32 @@ Specifies that the must serialize a particular class member as an array of XML elements. - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - You can apply the to a public field or read/write property that returns an array of objects. You can also apply it to collections and fields that return an or any field that returns an object that implements the interface. - - When you apply the to a class member, the method of the class generates a nested sequence of XML elements from that member. An XML schema document (an .xsd file), indicates such an array as a `complexType`. For example, if the class to be serialized represents a purchase order, you can generate an array of purchased items by applying the to a public field that returns an array of objects that represent order items. - - If no attributes are applied to a public field or property that returns an array of complex or primitive type objects, the generates a nested sequence of XML elements by default. To more precisely control what XML elements are generated, apply an and an to the field or property. For example, by default, the name of the generated XML element is derived from the member identifier You can change the name of the generated XML element by setting the property. - - If you serialize an array that contains items of a specific type and all the classes derived from that type, you must use the to declare each of the types. - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + You can apply the to a public field or read/write property that returns an array of objects. You can also apply it to collections and fields that return an or any field that returns an object that implements the interface. + + When you apply the to a class member, the method of the class generates a nested sequence of XML elements from that member. An XML schema document (an .xsd file), indicates such an array as a `complexType`. For example, if the class to be serialized represents a purchase order, you can generate an array of purchased items by applying the to a public field that returns an array of objects that represent order items. + + If no attributes are applied to a public field or property that returns an array of complex or primitive type objects, the generates a nested sequence of XML elements by default. To more precisely control what XML elements are generated, apply an and an to the field or property. For example, by default, the name of the generated XML element is derived from the member identifier You can change the name of the generated XML element by setting the property. + + If you serialize an array that contains items of a specific type and all the classes derived from that type, you must use the to declare each of the types. + > [!NOTE] -> You can use `XmlArray` in your code instead of the longer . - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example serializes a class instance into an XML document that contains several object arrays. The is applied to the members that become XML element arrays. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use `XmlArray` in your code instead of the longer . + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + + + +## Examples + The following example serializes a class instance into an XML document that contains several object arrays. The is applied to the members that become XML element arrays. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -150,20 +149,19 @@ Initializes a new instance of the class. - to two arrays. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp" id="Snippet1"::: + to two arrays. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -214,21 +212,20 @@ The name of the XML element that the generates. Initializes a new instance of the class and specifies the XML element name generated in the XML document instance. - to two arrays, and serializes a class instance that contains those arrays. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp" id="Snippet1"::: + to two arrays, and serializes a class instance that contains those arrays. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/.ctor/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/VB/source.vb" id="Snippet1"::: - :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/Common/MyClass1.xml" id="Snippet1"::: - + :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/Common/MyClass1.xml" id="Snippet1"::: + ]]> @@ -288,22 +285,21 @@ Gets or sets the XML element name given to the serialized array. The XML element name of the serialized array. The default is the name of the member to which the is assigned. - when you want the generated XML element name to differ from the member's identifier. - - You can set the same value to more than one member as long as the generated XML document uses XML namespaces to distinguish between the identically named members. For more details about using namespaces and creating prefixed names in the XML document, see . - - - -## Examples - The following example serializes an instance of the `Library` class that contains a property named `Books` that returns an array of `Book` items. The example uses the property to specify that the array of XML elements should be named `My_Books` rather than `Books`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp" id="Snippet1"::: + when you want the generated XML element name to differ from the member's identifier. + + You can set the same value to more than one member as long as the generated XML document uses XML namespaces to distinguish between the identically named members. For more details about using namespaces and creating prefixed names in the XML document, see . + + + +## Examples + The following example serializes an instance of the `Library` class that contains a property named `Books` that returns an array of `Book` items. The example uses the property to specify that the array of XML elements should be named `My_Books` rather than `Books`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/ElementName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -364,34 +360,33 @@ Gets or sets a value that indicates whether the XML element name generated by the is qualified or unqualified. One of the values. The default is . - property determines whether an XML element name is qualified or unqualified. The property conforms to the 1999 World Wide Web Consortium document titled [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). - - If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. - - The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: - -``` - - - - -``` - - When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. - - - -## Examples - The following example serializes an instance of the `Enterprises` class. Two XML elements have the same local name (`Company`) but different prefixes. The example sets the property is set to `XmlForm.Qualified` to ensure that the qualified names occur in the XML instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp" id="Snippet1"::: + + If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. + + The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: + +``` + + + + +``` + + When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. + + + +## Examples + The following example serializes an instance of the `Enterprises` class. Two XML elements have the same local name (`Company`) but different prefixes. The example sets the property is set to `XmlForm.Qualified` to ensure that the qualified names occur in the XML instance. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/Form/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -454,31 +449,30 @@ attributeFormDefault="unqualified"... > if the generates the attribute; otherwise, . - property is set to `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. - -``` - -``` - - If the property is `false`, no XML element is generated. - + + If the property is set to `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. + +``` + +``` + + If the property is `false`, no XML element is generated. + > [!NOTE] -> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. - - - -## Examples - The following example contains two arrays: one with the property set to `true`, and another with the property set to `false`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp" id="Snippet1"::: +> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. + + + +## Examples + The following example contains two arrays: one with the property set to `true`, and another with the property set to `false`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/IsNullable/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -537,22 +531,21 @@ attributeFormDefault="unqualified"... > Gets or sets the namespace of the XML element. The namespace of the XML element. - property allows you to create qualified XML element names. The property conforms to the rules for creating an XML namespace as found in the 1999 World Wide Web Consortium document titled [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). - - To create namespaces that are associated with a prefix, you must create an instance of the class that contains the namespaces and prefixes used in the XML document. As you set the namespace for each , it must match one of the namespaces in the . When the XML is generated, each array is correctly prefixed with the prefix associated with the specified namespace. - - - -## Examples - The following example serializes an instance of the `Library` class that contains two members, one that contain book titles, and another that contain periodical titles. Although both XML elements are named `Titles`, each contains a different prefix. The example also includes an instance of the class that contains the namespaces and prefixes used to qualify the two element names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp" id="Snippet1"::: + + To create namespaces that are associated with a prefix, you must create an instance of the class that contains the namespaces and prefixes used in the XML document. As you set the namespace for each , it must match one of the namespaces in the . When the XML is generated, each array is correctly prefixed with the prefix associated with the specified namespace. + + + +## Examples + The following example serializes an instance of the `Library` class that contains two members, one that contain book titles, and another that contain periodical titles. Although both XML elements are named `Titles`, each contains a different prefix. The example also includes an instance of the class that contains the namespaces and prefixes used to qualify the two element names. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/Namespace/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -609,14 +602,14 @@ attributeFormDefault="unqualified"... > Gets or sets the explicit order in which the elements are serialized or deserialized. The order of the code generation. - enumeration to instruct the to generate code that sets the property. - + enumeration to instruct the to generate code that sets the property. + > [!IMPORTANT] -> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. - +> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. + ]]> diff --git a/xml/System.Xml.Serialization/XmlArrayItemAttribute.xml b/xml/System.Xml.Serialization/XmlArrayItemAttribute.xml index 491697c7708..98641f2a3fd 100644 --- a/xml/System.Xml.Serialization/XmlArrayItemAttribute.xml +++ b/xml/System.Xml.Serialization/XmlArrayItemAttribute.xml @@ -61,35 +61,34 @@ Represents an attribute that specifies the derived types that the can place in a serialized array. - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - You can apply the to any public read/write member that returns an array, or provides access to one. For example, a field that returns an array of objects, a collection, an , or any class that implements the interface. - - The supports polymorphism--in other words, it allows the to add derived objects to an array. For example, suppose a class named `Mammal` is derived from a base class named `Animal`. Further suppose that a class named `MyAnimals` contains a field that returns an array of `Animal` objects. To allow the to serialize both the `Animal` and `Mammal` type, apply the to the field twice, each time specifying one of the two acceptable types. - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + You can apply the to any public read/write member that returns an array, or provides access to one. For example, a field that returns an array of objects, a collection, an , or any class that implements the interface. + + The supports polymorphism--in other words, it allows the to add derived objects to an array. For example, suppose a class named `Mammal` is derived from a base class named `Animal`. Further suppose that a class named `MyAnimals` contains a field that returns an array of `Animal` objects. To allow the to serialize both the `Animal` and `Mammal` type, apply the to the field twice, each time specifying one of the two acceptable types. + > [!NOTE] -> You can apply multiple instances of the or to specify types of objects that can be inserted into the array. - +> You can apply multiple instances of the or to specify types of objects that can be inserted into the array. + > [!NOTE] -> The serialization of a field or property that returns an interface or array of interfaces is not supported. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - +> The serialization of a field or property that returns an interface or array of interfaces is not supported. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlArrayItem` in your code instead of the longer . - - - -## Examples - The following example serializes a class named `Group` that contains a field named `Employees` that returns an array of `Employee` objects. The example applies the to the field, thereby instructing the that it can insert objects of both the base class (`Employee`) type and derived class type (`Manager`) into the serialized array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlArrayItem` in your code instead of the longer . + + + +## Examples + The following example serializes a class named `Group` that contains a field named `Employees` that returns an array of `Employee` objects. The example applies the to the field, thereby instructing the that it can insert objects of both the base class (`Employee`) type and derived class type (`Manager`) into the serialized array. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -159,15 +158,14 @@ Initializes a new instance of the class. - to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp" id="Snippet1"::: + to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -222,24 +220,23 @@ The name of the XML element. Initializes a new instance of the class and specifies the name of the XML element generated in the XML document. - property. - - Use this overload if you want the name of the generated XML element to differ from the member's identifier. - - An XML document that includes namespaces can contain more than one version of an element name. For details, see the property. - - - -## Examples - The following example serializes a class named `Transportation` that contains a field named `MyVehicles` that returns an array of `Vehicle` objects. The example applies the to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `elementName` parameter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp" id="Snippet1"::: + property. + + Use this overload if you want the name of the generated XML element to differ from the member's identifier. + + An XML document that includes namespaces can contain more than one version of an element name. For details, see the property. + + + +## Examples + The following example serializes a class named `Transportation` that contains a field named `MyVehicles` that returns an array of `Vehicle` objects. The example applies the to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `elementName` parameter. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/.ctor/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -294,15 +291,14 @@ The of the object to serialize. Initializes a new instance of the class and specifies the that can be inserted into the serialized array. - to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `type` parameter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp" id="Snippet1"::: + to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `type` parameter. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/.ctor/source2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -359,24 +355,23 @@ The of the object to serialize. Initializes a new instance of the class and specifies the name of the XML element generated in the XML document and the that can be inserted into the generated XML document. - and the properties. - - Use this overload if you want the name of the generated XML element to differ from the member's identifier. - - An XML document that includes namespaces can contain more than one version of an element name. For details, see the property. - - - -## Examples - The following example serializes a class named `Transportation` that contains a field named `MyVehicles` that returns an array of `Vehicle` objects. The example applies the to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `elementName` parameter, and the property using the `type` parameter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp" id="Snippet1"::: + and the properties. + + Use this overload if you want the name of the generated XML element to differ from the member's identifier. + + An XML document that includes namespaces can contain more than one version of an element name. For details, see the property. + + + +## Examples + The following example serializes a class named `Transportation` that contains a field named `MyVehicles` that returns an array of `Vehicle` objects. The example applies the to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `elementName` parameter, and the property using the `type` parameter. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/.ctor/source3.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -434,79 +429,78 @@ Gets or sets the XML data type of the generated XML element. An XML schema definition (XSD) data type. - objects, and apply an with the property set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XML Schema type that is mapped to a string, apply the with its property set to the XML Schema type. However, this does not change the serialization format, only the schema for the member. - + objects, and apply an with the property set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XML Schema type that is mapped to a string, apply the with its property set to the XML Schema type. However, this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. - +> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient then passing it as an XML attribute. - - For more information about XML Schema data types, see the World Wide Web Consortium document [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - The following example serializes a class named `PurchaseOrder`. Several instances of the class are applied to three members, and the property for each instance is set to a type allowed in the array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient then passing it as an XML attribute. + + For more information about XML Schema data types, see the World Wide Web Consortium document [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples + The following example serializes a class named `PurchaseOrder`. Several instances of the class are applied to three members, and the property for each instance is set to a type allowed in the array. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/DataType/arrayitem.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlArrayItemAttribute Example/VB/arrayitem.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlArrayItemAttribute Example/VB/arrayitem.vb" id="Snippet1"::: + ]]> @@ -564,22 +558,21 @@ Gets or sets the name of the generated XML element. The name of the generated XML element. The default is the member identifier. - if you want the name of the generated XML element to differ from the member's identifier. - - You can set the same value to more than one class member if the generated XML document uses XML namespaces to distinguish between identically named members. For details about how to use namespaces and prefixed names in the XML document, see the class. - - - -## Examples - The following example sets the property for the `Vehicle` and `Car` class--thereby changing the names of XML elements that the generates for those classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp" id="Snippet1"::: + if you want the name of the generated XML element to differ from the member's identifier. + + You can set the same value to more than one class member if the generated XML document uses XML namespaces to distinguish between identically named members. For details about how to use namespaces and prefixed names in the XML document, see the class. + + + +## Examples + The following example sets the property for the `Vehicle` and `Car` class--thereby changing the names of XML elements that the generates for those classes. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/ElementName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -637,32 +630,31 @@ Gets or sets a value that indicates whether the name of the generated XML element is qualified. One of the values. The default is . - property determines whether an XML element name is qualified, based on the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/xml-names/). - - If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. - - The default value, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. For elements, the checks the value of the schema-element attribute `elementFormDefault`. For attributes, it checks the value of the schema-element attribute `attributeFormDefault`. For example, the following XML Schema indicates that the `Name` element is qualified, while the `Number` element is unqualified. - -``` - - - - -``` - - - -## Examples - The following example sets the property for the `Vehicle` class to `XmlSchemaForm.Unqualified`, and the property for the `Car` class to `XmlSchemaForm.Qualified`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp" id="Snippet1"::: + property determines whether an XML element name is qualified, based on the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/xml-names/). + + If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. + + The default value, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. For elements, the checks the value of the schema-element attribute `elementFormDefault`. For attributes, it checks the value of the schema-element attribute `attributeFormDefault`. For example, the following XML Schema indicates that the `Name` element is qualified, while the `Number` element is unqualified. + +``` + + + + +``` + + + +## Examples + The following example sets the property for the `Vehicle` class to `XmlSchemaForm.Unqualified`, and the property for the `Car` class to `XmlSchemaForm.Qualified`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/Form/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/VB/source.vb" id="Snippet1"::: + ]]> The property is set to and a value is specified. @@ -718,31 +710,30 @@ attributeFormDefault="unqualified"> if the generates the attribute; otherwise, , and no instance is generated. The default is . - property is `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. - -``` - -``` - - If the property is `false`, no XML element is generated. - + property is `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. + +``` + +``` + + If the property is `false`, no XML element is generated. + > [!NOTE] -> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. - - - -## Examples - The following example serializes a class named `Group`, which contains a field named `Employees` that returns an array of `Employee` objects. A second class named `Manager` derives from `Employee`. An specifies that the can insert both `Employee` and `Manager` objects into the array. The example sets the property, thereby telling the not to generate the `xsi:nil` attribute objects in the array set to `null`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp" id="Snippet1"::: +> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. + + + +## Examples + The following example serializes a class named `Group`, which contains a field named `Employees` that returns an array of `Employee` objects. A second class named `Manager` derives from `Employee`. An specifies that the can insert both `Employee` and `Manager` objects into the array. The example sets the property, thereby telling the not to generate the `xsi:nil` attribute objects in the array set to `null`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/IsNullable/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -801,22 +792,21 @@ attributeFormDefault="unqualified"> Gets or sets the namespace of the generated XML element. The namespace of the generated XML element. - property conforms to the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/xml-names/). - - To create namespaces to use in the XML document and associated prefixes, you must create an that contains all the prefix and namespace pairs. The namespace you set for each must be contained in the . When the generates the document, it correctly prefixes the element name for each array item. - - - -## Examples - The following example applies an and sets the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp" id="Snippet1"::: + property conforms to the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/xml-names/). + + To create namespaces to use in the XML document and associated prefixes, you must create an that contains all the prefix and namespace pairs. The namespace you set for each must be contained in the . When the generates the document, it correctly prefixes the element name for each array item. + + + +## Examples + The following example applies an and sets the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/Namespace/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -874,21 +864,20 @@ attributeFormDefault="unqualified"> Gets or sets the level in a hierarchy of XML elements that the affects. The zero-based index of a set of indexes in an array of arrays. - property is only used when applying an to a field that returns an array of arrays. - - When applying the attribute, specify which hierarchy level the attribute affects by setting the . The first index always has the value of 0; therefore it is optional to set its --an without a value is applied to the first array index. Only the subsequent objects require values specified (as 1, 2, 3, and so forth). - - - -## Examples - The following example applies three attributes to an array of arrays. To specify which of the arrays each attribute applies to, the property is set to the index of the arrays. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/NestingLevel/nestinglevel.cs" id="Snippet1"::: - + property is only used when applying an to a field that returns an array of arrays. + + When applying the attribute, specify which hierarchy level the attribute affects by setting the . The first index always has the value of 0; therefore it is optional to set its --an without a value is applied to the first array index. Only the subsequent objects require values specified (as 1, 2, 3, and so forth). + + + +## Examples + The following example applies three attributes to an array of arrays. To specify which of the arrays each attribute applies to, the property is set to the index of the arrays. + + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/NestingLevel/nestinglevel.cs" id="Snippet1"::: + ]]> @@ -947,81 +936,80 @@ attributeFormDefault="unqualified"> Gets or sets the type allowed in an array. A that is allowed in the array. - property to specify an overridden type for a public field or public read/write property value. - - If a field or property returns an array of type , apply multiple instances of the to the field or property. For each instance, set the property to a type of object that can be inserted into the array. - - If an array contains only primitive types, you do not need to apply the . By default, the generates a series of elements, each with the same element name, for each value, but the type of each element is set to the XML Schema data type. For example, the following code: - -``` -' Visual Basic code -Public Class Arrays - Public XSDTypes ()As Object= New Object(){"one", 2, 3.0} -End Class -// C# code -public class MyArray{ - // No XmlArrayItemAttribute is applied. - public object[] XSDTypes= new object[]{"one", 2, 3.2}; -} -``` - - results in this XML: - -``` - - - - one - 2 - 3 - - -``` - - However, if you specify the property for each primitive type, the element name for each value is generated using the .NET type name. For example this code: - -``` -' Visual Basic code -Public Class Arrays - _ - Public PrimitiveTypes () As Object = New Object(){"one", 2, 3.0} -End Class -// C# code -public class Arrays{ - [XmlArrayItem(typeof(string))] - [XmlArrayItem(typeof(int))] - [XmlArrayItem(typeof(double))] - public object [] PrimitiveTypes = new object[]{"one", 2, 3.0}; -} -``` - - results in this XML: - -``` - - - - one - 2 - 3 - - -``` - - - -## Examples - The following example serializes an array of objects. The field that returns the array is attributed with two instances. Each instance instructs the to accept the specified in the array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp" id="Snippet1"::: + property to specify an overridden type for a public field or public read/write property value. + + If a field or property returns an array of type , apply multiple instances of the to the field or property. For each instance, set the property to a type of object that can be inserted into the array. + + If an array contains only primitive types, you do not need to apply the . By default, the generates a series of elements, each with the same element name, for each value, but the type of each element is set to the XML Schema data type. For example, the following code: + +``` +' Visual Basic code +Public Class Arrays + Public XSDTypes ()As Object= New Object(){"one", 2, 3.0} +End Class +// C# code +public class MyArray{ + // No XmlArrayItemAttribute is applied. + public object[] XSDTypes= new object[]{"one", 2, 3.2}; +} +``` + + results in this XML: + +``` + + + + one + 2 + 3 + + +``` + + However, if you specify the property for each primitive type, the element name for each value is generated using the .NET type name. For example this code: + +``` +' Visual Basic code +Public Class Arrays + _ + Public PrimitiveTypes () As Object = New Object(){"one", 2, 3.0} +End Class +// C# code +public class Arrays{ + [XmlArrayItem(typeof(string))] + [XmlArrayItem(typeof(int))] + [XmlArrayItem(typeof(double))] + public object [] PrimitiveTypes = new object[]{"one", 2, 3.0}; +} +``` + + results in this XML: + +``` + + + + one + 2 + 3 + + +``` + + + +## Examples + The following example serializes an array of objects. The field that returns the array is attributed with two instances. Each instance instructs the to accept the specified in the array. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/Type/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlAttributeAttribute.xml b/xml/System.Xml.Serialization/XmlAttributeAttribute.xml index 611b1ddb359..77e839f0cdc 100644 --- a/xml/System.Xml.Serialization/XmlAttributeAttribute.xml +++ b/xml/System.Xml.Serialization/XmlAttributeAttribute.xml @@ -73,49 +73,48 @@ Specifies that the must serialize the class member as an XML attribute. - belongs to a family of attributes that controls how the serializes, or deserializes, an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - When applied to a public field or property, the informs the to serialize the member as an XML attribute. By default, the serializes public fields and properties as XML elements. - - You can assign the only to public fields or public properties that return a value (or array of values) that can be mapped to one of the XML Schema definition language (XSD) simple types (including all built-in datatypes derived from the XSD `anySimpleType` type). The possible types include any that can be mapped to the XSD simple types, including , , and enumerations. See the property for a list of XSD types and how they are mapped to.NET data types. - - There are two special attributes that can be set with the : the `xml:lang` (specifies language) and `xml:space` (specifies how to handle white space) attributes. These attributes are intended to convey information that is relevant only to an application processing the XML. Examples of setting these are shown in the following code. - -```csharp -[XmlAttribute("xml:lang")] - public string Lang; - // Set this to 'default' or 'preserve'. - [XmlAttribute("space", - Namespace = "http://www.w3.org/XML/1998/namespace")] - public string Space + belongs to a family of attributes that controls how the serializes, or deserializes, an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + When applied to a public field or property, the informs the to serialize the member as an XML attribute. By default, the serializes public fields and properties as XML elements. + + You can assign the only to public fields or public properties that return a value (or array of values) that can be mapped to one of the XML Schema definition language (XSD) simple types (including all built-in datatypes derived from the XSD `anySimpleType` type). The possible types include any that can be mapped to the XSD simple types, including , , and enumerations. See the property for a list of XSD types and how they are mapped to.NET data types. + + There are two special attributes that can be set with the : the `xml:lang` (specifies language) and `xml:space` (specifies how to handle white space) attributes. These attributes are intended to convey information that is relevant only to an application processing the XML. Examples of setting these are shown in the following code. + +```csharp +[XmlAttribute("xml:lang")] + public string Lang; + // Set this to 'default' or 'preserve'. + [XmlAttribute("space", + Namespace = "http://www.w3.org/XML/1998/namespace")] + public string Space ``` - ```vb - _ - Public Lang As String - ' Set this to 'default' or 'preserve'. - _ - Public Space As String -``` - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + ```vb + _ + Public Lang As String + ' Set this to 'default' or 'preserve'. + _ + Public Space As String +``` + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlAttribute` in your code instead of the longer . - - - -## Examples - The following example serializes a class that contains several fields to which the is applied. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlAttribute` in your code instead of the longer . + + + +## Examples + The following example serializes a class that contains several fields to which the is applied. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -177,13 +176,12 @@ Initializes a new instance of the class. - @@ -241,13 +239,12 @@ The name of the XML attribute that the generates. Initializes a new instance of the class and specifies the name of the generated XML attribute. - @@ -420,20 +417,19 @@ Gets or sets the name of the XML attribute. The name of the XML attribute. The default is the member name. - property to specify an XML attribute name when the default value cannot be used. For example, if the XML attribute name is invalid as a member identifier, you can use a valid name for the identifier while setting the to an invalid name. - - - -## Examples - The following example sets the property of an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp" id="Snippet1"::: + property to specify an XML attribute name when the default value cannot be used. For example, if the XML attribute name is invalid as a member identifier, you can use a valid name for the identifier while setting the to an invalid name. + + + +## Examples + The following example sets the property of an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeAttribute/AttributeName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -495,79 +491,78 @@ Gets or sets the XSD data type of the XML attribute generated by the . An XSD (XML Schema Document) data type. - structures, and apply a with the property set to "base64Binary" or "hexBinary", as appropriate. For the XSD `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XSD type that is mapped to a string, apply the with its property set to the XSD type. However, this does not change the serialization format, only the schema for the member. - + structures, and apply a with the property set to "base64Binary" or "hexBinary", as appropriate. For the XSD `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XSD type that is mapped to a string, apply the with its property set to the XSD type. However, this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XSD data types. - +> The property is case-sensitive, so you must set it exactly to one of the XSD data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient than passing it as an XML attribute. - - For more information about XML data types, see the [XML Schema Part 2: DataTypes](https://www.w3.org/TR/xmlschema-2/) document from the World Wide Web Consortium. - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - The following example applies the to two members, and sets the property set to different values. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient than passing it as an XML attribute. + + For more information about XML data types, see the [XML Schema Part 2: DataTypes](https://www.w3.org/TR/xmlschema-2/) document from the World Wide Web Consortium. + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples + The following example applies the to two members, and sets the property set to different values. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeAttribute/DataType/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -628,34 +623,33 @@ Gets or sets a value that indicates whether the XML attribute name generated by the is qualified. One of the values. The default is . - property determines whether an XML element is qualified or unqualified. The property conforms to the 1999 http://www.w3.org specification `Namespaces in XML`. - - If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. - - The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: - -```xml - - - - -``` - - When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. - - - -## Examples - The following example applies the to two fields contained in a class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp" id="Snippet1"::: + property determines whether an XML element is qualified or unqualified. The property conforms to the 1999 http://www.w3.org specification `Namespaces in XML`. + + If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. + + The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: + +```xml + + + + +``` + + When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. + + + +## Examples + The following example applies the to two fields contained in a class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeAttribute/Form/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -717,22 +711,21 @@ attributeFormDefault="unqualified"... > Gets or sets the XML namespace of the XML attribute. The XML namespace of the XML attribute. - property conforms to the http://www.w3.org specification `Namespaces in XML`. - - To create namespaces that are associated with prefixes, you must create an object that contains the namespaces and prefixes used in the XML document. The namespace you set for each must match one of the namespaces in the object. When the generates the XML code, it correctly prefixes each attribute name. - - - -## Examples - The following example applies the to two fields contained in a class. The example sets the property for each attribute to a value different from the member identifier. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp" id="Snippet1"::: + property conforms to the http://www.w3.org specification `Namespaces in XML`. + + To create namespaces that are associated with prefixes, you must create an object that contains the namespaces and prefixes used in the XML document. The namespace you set for each must match one of the namespaces in the object. When the generates the XML code, it correctly prefixes each attribute name. + + + +## Examples + The following example applies the to two fields contained in a class. The example sets the property for each attribute to a value different from the member identifier. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeAttribute/Namespace/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlAttributeEventArgs.xml b/xml/System.Xml.Serialization/XmlAttributeEventArgs.xml index aa2f3502861..9f60d700c33 100644 --- a/xml/System.Xml.Serialization/XmlAttributeEventArgs.xml +++ b/xml/System.Xml.Serialization/XmlAttributeEventArgs.xml @@ -69,7 +69,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: @@ -135,7 +134,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: @@ -242,7 +240,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: @@ -307,7 +304,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: @@ -370,7 +366,6 @@ ## Examples The following example prints the value returned by the method when the method encounters an unknown attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/ObjectBeingDeserialized/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/XmlAttributeEventHandler.xml b/xml/System.Xml.Serialization/XmlAttributeEventHandler.xml index 3e567b92864..f6f32f211c9 100644 --- a/xml/System.Xml.Serialization/XmlAttributeEventHandler.xml +++ b/xml/System.Xml.Serialization/XmlAttributeEventHandler.xml @@ -60,29 +60,28 @@ An that contains the event data. Represents the method that handles the . - delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - The event occurs only when an object is being deserialized with the method. - - - -## Examples - The following example deserializes a class named `Group` from a file named UnknownAttributes.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownAttributes.xml. - -``` - - - MyGroup - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: + delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + The event occurs only when an object is being deserialized with the method. + + + +## Examples + The following example deserializes a class named `Group` from a file named UnknownAttributes.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownAttributes.xml. + +``` + + + MyGroup + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlAttributeOverrides.xml b/xml/System.Xml.Serialization/XmlAttributeOverrides.xml index 5ade2b5dacd..c5386f35a2b 100644 --- a/xml/System.Xml.Serialization/XmlAttributeOverrides.xml +++ b/xml/System.Xml.Serialization/XmlAttributeOverrides.xml @@ -85,7 +85,6 @@ ## Examples The following example serializes a class named `Orchestra`, which contains a single field named `Instruments` that returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example uses an instance of the class to override the `Instrument` field, allowing the field to accept `Brass` objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeOverrides/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/VB/source.vb" id="Snippet1"::: @@ -213,7 +212,6 @@ ## Examples The following example serializes a class named `Band`, which is derived from a class named `Orchestra`. The example creates an object, and assigns it to the property of an object. The example then calls the method to add the object to the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeOverrides/Add/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/VB/source.vb" id="Snippet1"::: @@ -293,7 +291,6 @@ ## Examples The following example creates an object, and assigns it to the property of an object. The example then adds the object to an object, before creating an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeOverrides/Add/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/VB/source.vb" id="Snippet1"::: @@ -379,7 +376,6 @@ ## Examples The following example creates an object, an object, and an object. The example assigns the to the property of the object, and adds the object to the object. Lastly, the example gets the object by passing the of the serialized class to the object. In this example, the is `Group`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeOverrides/Item/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/VB/source.vb" id="Snippet1"::: @@ -455,7 +451,6 @@ ## Examples The following example creates an object, an , and an object. The example assigns the to the property of the object and adds the object to the object. Lastly, the example gets the object by passing the of the serialized class and member name to the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeOverrides/Item/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/XmlAttributes.xml b/xml/System.Xml.Serialization/XmlAttributes.xml index 80c16cb2093..1140f63a8bd 100644 --- a/xml/System.Xml.Serialization/XmlAttributes.xml +++ b/xml/System.Xml.Serialization/XmlAttributes.xml @@ -69,7 +69,6 @@ ## Examples The following example serializes an instance of a class named `Orchestra`, which contains a single field named `Instruments` that returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example creates an object to override the `Instrument` field--allowing the field to accept `Brass` objects--and adds the object to an instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/VB/source.vb" id="Snippet1"::: @@ -138,7 +137,6 @@ ## Examples The following example serializes an instance of a class named `Orchestra`, which contains a single field named `Instruments` that returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example creates an object to override the `Instrument` field--allowing the field to accept `Brass` objects--and adds the object to an instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/VB/source.vb" id="Snippet1"::: @@ -325,7 +323,6 @@ ## Examples The following example creates a new object and adds it to the collection of objects accessed through the property. The object is then added to a object which is used to create an object. The is used to serialize or deserialize an object. To see the effect of using the property, create an XML document named "UnknownElements.xml" by running the `SerializeObject` method in the `Main` method. Edit the resulting document to include other (unknown) elements. Comment out the `SerializeObject` call in the `Main` method, and uncomment the call to the `DeserializeObject` method, which prints out the name and value of any unknown XML element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttributes/Overview/xmlanyover.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/VB/xmlanyover.vb" id="Snippet1"::: @@ -404,7 +401,6 @@ ## Examples The following example serializes a class that contains a field named `Members` that returns an array of objects. The is used to override the serialization of the field, and rename the element name to `Staff`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlArray/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/VB/source.vb" id="Snippet1"::: @@ -473,7 +469,6 @@ ## Examples The following example serializes a class that contains a field named `Members` that returns an array of objects. Two objects are created to allow the field to accept objects that derive from the base class named `Member`. Each object is added to the through the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlArrayItems/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/VB/source.vb" id="Snippet1"::: @@ -545,7 +540,6 @@ ## Examples The following example serializes a class named `Group` that contains a property named `GroupName`; the `GroupName` property is serialized as an XML attribute. The example creates an and an object to override the default serialization of the field. The example then creates an to specifically override the property, and the object is set to the property The object is added to the object with the name of the overridden member specified. Finally, an is constructed and returned using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/VB/source.vb" id="Snippet1"::: @@ -688,7 +682,6 @@ ## Examples The following example shows a class named `Pet` that contains a field that has a default value set to "Dog". However, the example also creates an object, and sets its property to a new default value ("Cat"). This overrides the original default value. Thus, if the field value is set to "Cat", the treats it as the default value, and not serialize it. If it is set to any other value, the serializes the value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlDefaultValue/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/VB/source.vb" id="Snippet1"::: @@ -757,7 +750,6 @@ ## Examples The following example serializes the `Transportation` class, which contains a single field named `Vehicles` that returns an . The example applies two attributes to the `Vehicles` field. The example creates two objects and adds them to the collection of an object. To allow the array to accept different object types, the object is added to the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlElements/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/VB/source.vb" id="Snippet1"::: @@ -827,7 +819,6 @@ ## Examples The following example serializes two classes named `Food` and `FoodType`. The `FoodType` class contains two enumerations that are overridden and, for each enumeration, the example creates an object that it assigns to the property of an object. The example then adds the object to an object, which is used to create an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlEnum/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/VB/source.vb" id="Snippet1"::: @@ -901,7 +892,6 @@ ## Examples The following example serializes a class named `Group`, which contains a member named `Comment` to which the is applied. The example creates an object, and sets the property to `false`, thereby overriding the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlIgnore/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/VB/source.vb" id="Snippet1"::: @@ -969,7 +959,6 @@ ## Examples The following example contains a class named `Student`. The class contains a member named `MyNamespaces` that returns an object. The example creates an object that is added to an instance of the class. The property is set to `true`, which instructs the to preserve the namespaces when the serialization of the `Student` object is overridden. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/Xmlns/xmlns.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/VB/xmlns.vb" id="Snippet1"::: @@ -1036,7 +1025,6 @@ ## Examples The following example creates an object, an object, and an object. The example assigns the to the property of the object, and adds the object to the object. Lastly, the example gets the object by passing the of the serialized class to the object. (In this example, the is `Group`.) - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlRoot/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/VB/source.vb" id="Snippet1"::: @@ -1111,7 +1099,6 @@ ## Examples The following example serializes the class named `Group`, which contains a field named `Comment`. To override the default way the serializes the field, the example creates an and an object. The example then creates an object, which it assigns to the property, and adds the object (with the name of the field to be serialized as XML text) to the object. Lastly the example creates an using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlText/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/VB/source.vb" id="Snippet1"::: @@ -1181,7 +1168,6 @@ ## Examples The following example creates an object, and assigns it to the property of an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/XmlChoiceIdentifierAttribute.xml b/xml/System.Xml.Serialization/XmlChoiceIdentifierAttribute.xml index 7b2a65d7dfc..3835a711151 100644 --- a/xml/System.Xml.Serialization/XmlChoiceIdentifierAttribute.xml +++ b/xml/System.Xml.Serialization/XmlChoiceIdentifierAttribute.xml @@ -61,113 +61,112 @@ Specifies that the member can be further detected by using an enumeration. - - - - - - - - -``` - - The allows you to assign a special enumeration value to each instance of the member. You must either create the enumeration yourself or it can be generated by the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The following C# code shows how the is applied to an `Item` field; the property identifies the field that contains the enumeration that is further used to detect the choice. - -``` -public class Choices{ - [XmlChoiceIdentifier("ItemType")] - [XmlChoiceIdentifier("ChoiceOne")] - [XmlChoiceIdentifier("ChoiceTwo")] - public string MyChoice; - - // Do not serialize this next field: - [XmlIgnore] - public ItemChoiceType ItemType; -} -// Do not include this enumeration in the XML schema. -[XmlType(IncludeInSchema = false)] -public enum ItemChoiceType{ - ChoiceOne, - ChoiceTwo, -} -``` - - When this code is in place, you can serialize and deserialize this class by setting the `ItemType` field to an appropriate enumeration. For example, to serialize the `Choice` class, the C# code resembles the following. - -``` -Choices mc = new Choices(); -mc.MyChoice = "Item Choice One"; -mc.ItemType = ItemChoiceType.ChoiceOne; -``` - - When deserializing, the C# code resembles the following: - -``` -MyChoice mc = (MyChoice) myXmlSerializer.Deserialize(myReader); -if(mc.ItemType == ItemChoiceType.ChoiceOne) - { - // Handle choice one. - } -if(mc.ItemType == ItemChoiceType.ChoiceTwo) - { - // Handle choice two. - } -if(mc.ItemType != null) - { - throw CreateUnknownTypeException(mc.Item); - } -``` - - There is a second scenario when the is used. In the following schema, the member is a field that returns an array of items (maxOccurs="unbounded"). The array can contain objects of the first choice ("D-a-t-a"), and of the second choice ("MoreData"). - -``` - - - - - - - - -``` - - The resulting class then uses a field to return an array of items. For each item in the array, a corresponding `ItemChoiceType` enumeration must also be found. The matching enumerations are contained in the array returned by the `ItemsElementName` field. - -``` -public class MyChoice { - [System.Xml.Serialization.XmlElementAttribute("D-a-t-a", typeof(string), IsNullable=false)] - [System.Xml.Serialization.XmlElementAttribute("MoreData", typeof(string), IsNullable=false)] - [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")] - public string[] Items; - [System.Xml.Serialization.XmlElementAttribute(IsNullable=false)] - [System.Xml.Serialization.XmlIgnoreAttribute()] - public ItemsChoiceType[] ItemsElementName; -} -[System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)] -public enum ItemsChoiceType { - [System.Xml.Serialization.XmlEnumAttribute("D-a-t-a")] - Data, - MoreData, -} -``` - - When deserializing an object that includes a range of choices, use a control structure (such as an if...then...else structure) to determine how to deserialize a particular value. In the control structure, check the enumeration value and deserialize the value accordingly. - - - -## Examples - The following example serializes a class named `Choices` that includes two fields, `MyChoice` and `ManyChoices`. The is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp" id="Snippet1"::: + + + + + + + + +``` + + The allows you to assign a special enumeration value to each instance of the member. You must either create the enumeration yourself or it can be generated by the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The following C# code shows how the is applied to an `Item` field; the property identifies the field that contains the enumeration that is further used to detect the choice. + +``` +public class Choices{ + [XmlChoiceIdentifier("ItemType")] + [XmlChoiceIdentifier("ChoiceOne")] + [XmlChoiceIdentifier("ChoiceTwo")] + public string MyChoice; + + // Do not serialize this next field: + [XmlIgnore] + public ItemChoiceType ItemType; +} +// Do not include this enumeration in the XML schema. +[XmlType(IncludeInSchema = false)] +public enum ItemChoiceType{ + ChoiceOne, + ChoiceTwo, +} +``` + + When this code is in place, you can serialize and deserialize this class by setting the `ItemType` field to an appropriate enumeration. For example, to serialize the `Choice` class, the C# code resembles the following. + +``` +Choices mc = new Choices(); +mc.MyChoice = "Item Choice One"; +mc.ItemType = ItemChoiceType.ChoiceOne; +``` + + When deserializing, the C# code resembles the following: + +``` +MyChoice mc = (MyChoice) myXmlSerializer.Deserialize(myReader); +if(mc.ItemType == ItemChoiceType.ChoiceOne) + { + // Handle choice one. + } +if(mc.ItemType == ItemChoiceType.ChoiceTwo) + { + // Handle choice two. + } +if(mc.ItemType != null) + { + throw CreateUnknownTypeException(mc.Item); + } +``` + + There is a second scenario when the is used. In the following schema, the member is a field that returns an array of items (maxOccurs="unbounded"). The array can contain objects of the first choice ("D-a-t-a"), and of the second choice ("MoreData"). + +``` + + + + + + + + +``` + + The resulting class then uses a field to return an array of items. For each item in the array, a corresponding `ItemChoiceType` enumeration must also be found. The matching enumerations are contained in the array returned by the `ItemsElementName` field. + +``` +public class MyChoice { + [System.Xml.Serialization.XmlElementAttribute("D-a-t-a", typeof(string), IsNullable=false)] + [System.Xml.Serialization.XmlElementAttribute("MoreData", typeof(string), IsNullable=false)] + [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")] + public string[] Items; + [System.Xml.Serialization.XmlElementAttribute(IsNullable=false)] + [System.Xml.Serialization.XmlIgnoreAttribute()] + public ItemsChoiceType[] ItemsElementName; +} +[System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)] +public enum ItemsChoiceType { + [System.Xml.Serialization.XmlEnumAttribute("D-a-t-a")] + Data, + MoreData, +} +``` + + When deserializing an object that includes a range of choices, use a control structure (such as an if...then...else structure) to determine how to deserialize a particular value. In the control structure, check the enumeration value and deserialize the value accordingly. + + + +## Examples + The following example serializes a class named `Choices` that includes two fields, `MyChoice` and `ManyChoices`. The is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlChoiceIdentifierAttribute/Overview/choice.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: + ]]> @@ -233,15 +232,14 @@ public enum ItemsChoiceType { Initializes a new instance of the class. - is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp" id="Snippet1"::: + is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlChoiceIdentifierAttribute/Overview/choice.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: + ]]> @@ -347,20 +345,19 @@ public enum ItemsChoiceType { Gets or sets the name of the field that returns the enumeration to use when detecting types. The name of a field that returns an enumeration. - value. By default, that enumeration name takes the name of the field that the is applied to. - - - -## Examples - The following example serializes a class named `Choices` that includes two fields, `MyChoice` and `ManyChoices`. The is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp" id="Snippet1"::: + value. By default, that enumeration name takes the name of the field that the is applied to. + + + +## Examples + The following example serializes a class named `Choices` that includes two fields, `MyChoice` and `ManyChoices`. The is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlChoiceIdentifierAttribute/Overview/choice.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlElementAttribute.xml b/xml/System.Xml.Serialization/XmlElementAttribute.xml index baa7de0acd0..132dd255fac 100644 --- a/xml/System.Xml.Serialization/XmlElementAttribute.xml +++ b/xml/System.Xml.Serialization/XmlElementAttribute.xml @@ -73,59 +73,58 @@ Indicates that a public field or property represents an XML element when the serializes or deserializes the object that contains it. - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - An XML document usually contains XML elements, each of which consists of three parts: an opening tag with possible attributes, a closing tag, and the data between the tags. XML tags can be nested--that is, the data between tags can also be XML elements. This capacity of one element to enclose another allows the document to contain hierarchies of data. An XML element can also include attributes. - - Apply the to public fields or public read/write properties to control characteristics of the XML elements such as the element name and namespace. - - The can be applied multiple times to a field that returns an array of objects. The purpose of this is to specify (through the property) different types that can be inserted into the array. For example, the array in the following C# code accepts both strings and integers. - -``` -public class Things{ - [XmlElement(Type = typeof(string)), - XmlElement(Type = typeof(int))] - public object[] StringsAndInts; -} -``` - - This results in XML that might resemble the following. - -``` - - Hello - 999 - World - -``` - - Note that when you apply the multiple times without specifying an property value, the elements are named after the type of the acceptable objects. - - If you apply the to a field or property that returns an array, the items in the array are encoded as a sequence of XML elements. - - In contrast if an is not applied to such a field or property, the items in the array are encoded as a sequence of elements, nested under an element named after the field or property. (Use the and attributes to control how an array is serialized.) - - You can set the property to specify a type that is derived from the type of the original field or property--that is, the field or property to which you have applied the . - - If a field or property returns an , you can apply multiple instances of the to the member. For each instance, set the property to a type of object that can be inserted into the array. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + An XML document usually contains XML elements, each of which consists of three parts: an opening tag with possible attributes, a closing tag, and the data between the tags. XML tags can be nested--that is, the data between tags can also be XML elements. This capacity of one element to enclose another allows the document to contain hierarchies of data. An XML element can also include attributes. + + Apply the to public fields or public read/write properties to control characteristics of the XML elements such as the element name and namespace. + + The can be applied multiple times to a field that returns an array of objects. The purpose of this is to specify (through the property) different types that can be inserted into the array. For example, the array in the following C# code accepts both strings and integers. + +``` +public class Things{ + [XmlElement(Type = typeof(string)), + XmlElement(Type = typeof(int))] + public object[] StringsAndInts; +} +``` + + This results in XML that might resemble the following. + +``` + + Hello + 999 + World + +``` + + Note that when you apply the multiple times without specifying an property value, the elements are named after the type of the acceptable objects. + + If you apply the to a field or property that returns an array, the items in the array are encoded as a sequence of XML elements. + + In contrast if an is not applied to such a field or property, the items in the array are encoded as a sequence of elements, nested under an element named after the field or property. (Use the and attributes to control how an array is serialized.) + + You can set the property to specify a type that is derived from the type of the original field or property--that is, the field or property to which you have applied the . + + If a field or property returns an , you can apply multiple instances of the to the member. For each instance, set the property to a type of object that can be inserted into the array. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlElement` in your code instead of the longer . - - - -## Examples - The following example serializes a class named `Group` and applies the to several of its members. The field named `Employees` returns an array of `Employee` objects. In this case, the specifies that the resulting XML will not be nested (which is the default behavior of items in an array). - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlElement` in your code instead of the longer . + + + +## Examples + The following example serializes a class named `Group` and applies the to several of its members. The field named `Employees` returns an array of `Employee` objects. In this case, the specifies that the resulting XML will not be nested (which is the default behavior of items in an array). + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -193,15 +192,14 @@ public class Things{ Initializes a new instance of the class. - to a class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp" id="Snippet1"::: + to a class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -253,20 +251,19 @@ public class Things{ The XML element name of the serialized member. Initializes a new instance of the class and specifies the name of the XML element. - uses the member name as the XML element name when serializing a class instance. For example, a field named `Vehicle` generates an XML element named `Vehicle`. However if you need a different element, such as `Cars`, pass it in the `elementName` parameter. - - - -## Examples - The following example shows a simple class that contains a single field named `Vehicles`. The example applies the to the field and includes the `elementName` parameter, thereby instructing the to generate XML elements named "Cars" rather than "Vehicles". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp" id="Snippet1"::: + uses the member name as the XML element name when serializing a class instance. For example, a field named `Vehicle` generates an XML element named `Vehicle`. However if you need a different element, such as `Cars`, pass it in the `elementName` parameter. + + + +## Examples + The following example shows a simple class that contains a single field named `Vehicles`. The example applies the to the field and includes the `elementName` parameter, thereby instructing the to generate XML elements named "Cars" rather than "Vehicles". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/.ctor/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -318,20 +315,19 @@ public class Things{ The of an object derived from the member's type. Initializes a new instance of the class and specifies a type for the member to which the is applied. This type is used by the when serializing or deserializing object that contains it. - to accept the `Mammal` class when it serializes the `MyAnimal` property, pass the of the `Mammal` class to the constructor. - - - -## Examples - The following example serializes a class named `Orchestra` that contains a single field named `Instruments`, which returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example applies the to the `Instruments` field, and specifies the `Brass` type, allowing the `Instruments` field to accept `Brass` objects. The example also specifies the name of the XML element by setting the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp" id="Snippet1"::: + to accept the `Mammal` class when it serializes the `MyAnimal` property, pass the of the `Mammal` class to the constructor. + + + +## Examples + The following example serializes a class named `Orchestra` that contains a single field named `Instruments`, which returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example applies the to the `Instruments` field, and specifies the `Brass` type, allowing the `Instruments` field to accept `Brass` objects. The example also specifies the name of the XML element by setting the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/.ctor/source2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -385,22 +381,21 @@ public class Things{ The of an object derived from the member's type. Initializes a new instance of the and specifies the name of the XML element and a derived type for the member to which the is applied. This member type is used when the serializes the object that contains it. - uses the member name as the XML element name when serializing a class instance. For example, a field named `Vehicle` generates an XML element named `Vehicle`. However, if you need a different element, such as `Cars`, pass it in the `elementName` parameter. - - Use the `type` parameter to specify a type that is derived from a base class. For example, suppose a property named `MyAnimal` returns an `Animal` object. You want to enhance the object, so you create a new class named `Mammal` that inherits from the `Animal` class. To instruct the to accept the `Mammal` class when it serializes the `MyAnimal` property, pass the of the `Mammal` class to the constructor. - - - -## Examples - The following example serializes a class named `Orchestra` that contains a single field named `Instruments`, which returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example applies the to the `Instruments` field, and specifies the `Brass` type, allowing the `Instruments` field to accept `Brass` objects. The example also specifies the name of the XML element by setting the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp" id="Snippet1"::: + uses the member name as the XML element name when serializing a class instance. For example, a field named `Vehicle` generates an XML element named `Vehicle`. However, if you need a different element, such as `Cars`, pass it in the `elementName` parameter. + + Use the `type` parameter to specify a type that is derived from a base class. For example, suppose a property named `MyAnimal` returns an `Animal` object. You want to enhance the object, so you create a new class named `Mammal` that inherits from the `Animal` class. To instruct the to accept the `Mammal` class when it serializes the `MyAnimal` property, pass the of the `Mammal` class to the constructor. + + + +## Examples + The following example serializes a class named `Orchestra` that contains a single field named `Instruments`, which returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example applies the to the `Instruments` field, and specifies the `Brass` type, allowing the `Instruments` field to accept `Brass` objects. The example also specifies the name of the XML element by setting the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/.ctor/source2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -461,79 +456,78 @@ public class Things{ Gets or sets the XML Schema definition (XSD) data type of the XML element generated by the . An XML Schema data type. - structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XML Schema type that is mapped to a string, apply the with its property set to the XML Schema type. It is possible that this can change the serialization format, not only the schema for the member. - + structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XML Schema type that is mapped to a string, apply the with its property set to the XML Schema type. It is possible that this can change the serialization format, not only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. - +> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient than passing it as an XML Schema attribute. - - For more information about XML data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - The following example serializes a class named `Group` that contains a field named `ExtraInfo`, which returns an . The example applies two instances of the to the field and specifies different values for each instance. Each instance enables the to serialize the specified types inserted into the array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient than passing it as an XML Schema attribute. + + For more information about XML data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples + The following example serializes a class named `Group` that contains a field named `ExtraInfo`, which returns an . The example applies two instances of the to the field and specifies different values for each instance. Each instance enables the to serialize the specified types inserted into the array. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/DataType/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/VB/source.vb" id="Snippet1"::: + ]]> The XML Schema data type you have specified cannot be mapped to the.NET data type. @@ -595,22 +589,21 @@ public class Things{ Gets or sets the name of the generated XML element. The name of the generated XML element. The default is the member identifier. - if you want the name of the generated XML element to differ from the member's identifier. - - You can set the same value to more than one class member if the generated XML document uses XML namespaces to distinguish between the identically named members. For details on how to use namespaces and prefixed names in the XML document, see the class. - - - -## Examples - The following example sets the property of an to a new value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp" id="Snippet1"::: + if you want the name of the generated XML element to differ from the member's identifier. + + You can set the same value to more than one class member if the generated XML document uses XML namespaces to distinguish between the identically named members. For details on how to use namespaces and prefixed names in the XML document, see the class. + + + +## Examples + The following example sets the property of an to a new value. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/ElementName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -672,32 +665,31 @@ public class Things{ Gets or sets a value that indicates whether the element is qualified. One of the values. The default is . - property determines whether an XML element is qualified or unqualified. The property conforms to the World Wide Web Consortium 1999 specification, [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). - - If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: - -``` - - - - -``` - - When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. - - - -## Examples - The following example sets the property to `XmlSchemaForm.Unqualified`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp" id="Snippet1"::: + property determines whether an XML element is qualified or unqualified. The property conforms to the World Wide Web Consortium 1999 specification, [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). + + If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: + +``` + + + + +``` + + When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. + + + +## Examples + The following example sets the property to `XmlSchemaForm.Unqualified`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/Form/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -755,31 +747,30 @@ attributeFormDefault="unqualified"... > if the generates the attribute; otherwise, . - property is set to `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example if you set a field named `MyStringArray` to `null`, the generates the following XML code. - -``` - -``` - - If the property is `false`, no XML element is generated for class members that have been set to `null`. - + + If the property is set to `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example if you set a field named `MyStringArray` to `null`, the generates the following XML code. + +``` + +``` + + If the property is `false`, no XML element is generated for class members that have been set to `null`. + > [!NOTE] -> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. Additionally, you cannot set this property to `false` for nullable value types. When such types are `null`, they will be serialized by setting `xsi:nil` to `true`. - - - -## Examples - The following example shows a field with the applied to it, and the property set to `false`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp" id="Snippet1"::: +> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. Additionally, you cannot set this property to `false` for nullable value types. When such types are `null`, they will be serialized by setting `xsi:nil` to `true`. + + + +## Examples + The following example shows a field with the applied to it, and the property set to `false`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/IsNullable/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -841,13 +832,13 @@ attributeFormDefault="unqualified"... > Gets or sets the namespace assigned to the XML element that results when the class is serialized. The namespace of the XML element. - property conforms to the World Wide Web Consortium specification, [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). - - To create namespaces that are associated with a prefix, you must create an that contains the namespaces and prefixes used in the XML document. As you set the namespace for each , it must match one of the namespaces in the . When the XML is generated, each array is correctly prefixed with the prefix associated with the specified namespace. - + property conforms to the World Wide Web Consortium specification, [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). + + To create namespaces that are associated with a prefix, you must create an that contains the namespaces and prefixes used in the XML document. As you set the namespace for each , it must match one of the namespaces in the . When the XML is generated, each array is correctly prefixed with the prefix associated with the specified namespace. + ]]> @@ -903,14 +894,14 @@ attributeFormDefault="unqualified"... > Gets or sets the explicit order in which the elements are serialized or deserialized. The order of the code generation. - enumeration to instruct the to generate code that sets the property. - + enumeration to instruct the to generate code that sets the property. + > [!IMPORTANT] -> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. - +> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. + ]]> @@ -972,22 +963,21 @@ attributeFormDefault="unqualified"... > Gets or sets the object type used to represent the XML element. The of the member. - property to specify a derived type for a field or property. - - If a field or property returns an , you can apply multiple instances of the to the member. For each instance, set the property to a type of object that can be inserted into the array. - - - -## Examples - The following example uses the property to specify a derived object for an . The example also applies three instances of the to a field that returns an . Each instance specifies a type allowed in the field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp" id="Snippet1"::: + property to specify a derived type for a field or property. + + If a field or property returns an , you can apply multiple instances of the to the member. For each instance, set the property to a type of object that can be inserted into the array. + + + +## Examples + The following example uses the property to specify a derived object for an . The example also applies three instances of the to a field that returns an . Each instance specifies a type allowed in the field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/Type/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlElementAttributes.xml b/xml/System.Xml.Serialization/XmlElementAttributes.xml index c712b7cf210..17a9070436f 100644 --- a/xml/System.Xml.Serialization/XmlElementAttributes.xml +++ b/xml/System.Xml.Serialization/XmlElementAttributes.xml @@ -73,20 +73,19 @@ Represents a collection of objects used by the to override the default way it serializes a class. - is returned by the property of the class. By using the class and the class, you can override the default way that the serializes a class. - - - -## Examples - The following example serializes the `Transportation` class, which contains a single field named `Vehicles` that returns an . The example first applies two instances of the class to the `Vehicles` field that specifies the types of objects the inserts into the array. The example then creates two objects to override the behavior of the attributes applied to the `Vehicles` property. The two overriding objects are added to the collection of an . Lastly, the example adds the to an , allowing the to insert the new object types into the returned by the `Vehicles` field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp" id="Snippet1"::: + is returned by the property of the class. By using the class and the class, you can override the default way that the serializes a class. + + + +## Examples + The following example serializes the `Transportation` class, which contains a single field named `Vehicles` that returns an . The example first applies two instances of the class to the `Vehicles` field that specifies the types of objects the inserts into the array. The example then creates two objects to override the behavior of the attributes applied to the `Vehicles` property. The two overriding objects are added to the collection of an . Lastly, the example adds the to an , allowing the to insert the new object types into the returned by the `Vehicles` field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttributes/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttributes Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttributes Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -192,15 +191,14 @@ Adds an to the collection. The zero-based index of the newly added item. - objects and calls the method to add them to an . The example then adds the to an , which is used to create an that can serialize an instance of the `Transportation` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp" id="Snippet1"::: + objects and calls the method to add them to an . The example then adds the to an , which is used to create an that can serialize an instance of the `Transportation` class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttributes/Add/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlElementEventArgs.xml b/xml/System.Xml.Serialization/XmlElementEventArgs.xml index 1bd7bcbc624..1f0b5c8d75a 100644 --- a/xml/System.Xml.Serialization/XmlElementEventArgs.xml +++ b/xml/System.Xml.Serialization/XmlElementEventArgs.xml @@ -50,32 +50,31 @@ Provides data for the event. - event occurs only when you call the method. - - - -## Examples - The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: + event occurs only when you call the method. + + + +## Examples + The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: + ]]> @@ -125,25 +124,24 @@ Gets the object that represents the unknown XML element. The object that represents the unknown XML element. - event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: + event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: + ]]> @@ -233,30 +231,29 @@ Gets the line number where the unknown element was encountered if the XML reader is an . The line number where the unknown element was encountered if the XML reader is an ; otherwise, -1. - property returns a value only if the underlying XML reader is an . - - - -## Examples - The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: + property returns a value only if the underlying XML reader is an . + + + +## Examples + The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: + ]]> @@ -306,25 +303,24 @@ Gets the place in the line where the unknown element occurs if the XML reader is an . The number in the line where the unknown element occurs if the XML reader is an ; otherwise, -1. - event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: + event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: + ]]> @@ -379,23 +375,23 @@ Gets the object the is deserializing. The object that is being deserialized by the . - event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - XmlSerializer.UnknownElement Example#1 - + event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + + XmlSerializer.UnknownElement Example#1 + ]]> diff --git a/xml/System.Xml.Serialization/XmlElementEventHandler.xml b/xml/System.Xml.Serialization/XmlElementEventHandler.xml index 0c1a1583a59..ea6a8dec8fe 100644 --- a/xml/System.Xml.Serialization/XmlElementEventHandler.xml +++ b/xml/System.Xml.Serialization/XmlElementEventHandler.xml @@ -60,32 +60,31 @@ A that contains the event data. Represents the method that handles the event of an . - delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - The event occurs only when you call the method. - - - -## Examples - The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: + delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + The event occurs only when you call the method. + + + +## Examples + The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlEnumAttribute.xml b/xml/System.Xml.Serialization/XmlEnumAttribute.xml index 71fa2c60017..e0aa2e47953 100644 --- a/xml/System.Xml.Serialization/XmlEnumAttribute.xml +++ b/xml/System.Xml.Serialization/XmlEnumAttribute.xml @@ -73,30 +73,29 @@ Controls how the serializes an enumeration member. - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - Use the to change the enumeration that the generates or recognizes (when it serializes or deserializes a class, respectively). For example, if an enumeration contains a member named `One`, but you prefer that the XML output be named `Single`, apply the to the enumeration member and set the property to "Single". - - You can override the property value of an by creating an instance of the class and assigning it to the property of an object. For details, see the class. - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + Use the to change the enumeration that the generates or recognizes (when it serializes or deserializes a class, respectively). For example, if an enumeration contains a member named `One`, but you prefer that the XML output be named `Single`, apply the to the enumeration member and set the property to "Single". + + You can override the property value of an by creating an instance of the class and assigning it to the property of an object. For details, see the class. + > [!NOTE] -> You can use the word `XmlEnum` in your code instead of the longer . - - - -## Examples - The following example applies the to the members of an enumeration. When the generates XML data for this enumeration, the data conforms to the values of the properties. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlEnum` in your code instead of the longer . + + + +## Examples + The following example applies the to the members of an enumeration. When the generates XML data for this enumeration, the data conforms to the values of the properties. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlEnumAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/VB/source.vb" id="Snippet1"::: + > [!NOTE] -> You can use the word `XmlEnum` in your code instead of the longer . - +> You can use the word `XmlEnum` in your code instead of the longer . + ]]> @@ -169,23 +168,22 @@ Initializes a new instance of the class. - to override an existing enumeration. - + to override an existing enumeration. + > [!NOTE] -> You can use the word `XmlEnum` in your code instead of the longer . - - - -## Examples - The following example serializes two classes named `Food` and `FoodType`. The `FoodType` class contains two enumerations that are overridden and, for each enumeration, the example creates an object that is assigned to the property of an object. The example then adds the object to an object, which is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlEnum` in your code instead of the longer . + + + +## Examples + The following example serializes two classes named `Food` and `FoodType`. The `FoodType` class contains two enumerations that are overridden and, for each enumeration, the example creates an object that is assigned to the property of an object. The example then adds the object to an object, which is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlEnumAttribute/.ctor/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -246,22 +244,21 @@ The overriding name of the enumeration member. Initializes a new instance of the class, and specifies the XML value that the generates or recognizes (when it serializes or deserializes the enumeration, respectively). - [!NOTE] -> You can use the word `XmlEnum` in your code instead of the longer . - - - -## Examples - The following example applies the to the members of an enumeration. When the generates XML data for this enumeration, the data conforms to the values of the properties. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlEnum` in your code instead of the longer . + + + +## Examples + The following example applies the to the members of an enumeration. When the generates XML data for this enumeration, the data conforms to the values of the properties. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlEnumAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -326,23 +323,22 @@ Gets or sets the value generated in an XML-document instance when the serializes an enumeration, or the value recognized when it deserializes the enumeration member. The value generated in an XML-document instance when the serializes the enumeration, or the value recognized when it is deserializes the enumeration member. - when you want the generated XML data to differ from the enumeration identifier. - + when you want the generated XML data to differ from the enumeration identifier. + > [!NOTE] -> You can use the word `XmlEnum` in your code instead of the longer . - - - -## Examples - The following example applies the attribute to members of an enumeration. The generated XML data conforms to the values set for the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlEnum` in your code instead of the longer . + + + +## Examples + The following example applies the attribute to members of an enumeration. The generated XML data conforms to the values set for the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlEnumAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlIgnoreAttribute.xml b/xml/System.Xml.Serialization/XmlIgnoreAttribute.xml index 3e0940d42c4..00fa03b8401 100644 --- a/xml/System.Xml.Serialization/XmlIgnoreAttribute.xml +++ b/xml/System.Xml.Serialization/XmlIgnoreAttribute.xml @@ -69,29 +69,28 @@ Instructs the method of the not to serialize the public field or public read/write property value. - belongs to a family of attributes that controls how the serializes or deserializes an object. If you apply the to any member of a class, the ignores the member when serializing or deserializing an instance of the class. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - You can override the behavior caused by the by creating an object, and setting its property to `false`. You must the object to an instance of the class. Lastly, you must use the object to construct an instance of the class before you call the or methods. - - The [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) occasionally generates the when creating classes from a schema file (.xsd). This behavior occurs because value types cannot be set to `null`, but all XML data types can be. Therefore, the tool creates two fields when it encounters an XML type that maps to a value type: one to hold the value and another special field that takes the form of `fieldnameSpecified`, where the `fieldname` is replaced by the name of the field or property. Notice, however, that this special field is generated only when the schema specifies that the element has no minimum occurrence (minOccurs = "0") and that the element has no default value. The sets and checks this special field to determine whether a value has been set for the field or property. Because the special field must not be serialized, the tool applies the to it. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + belongs to a family of attributes that controls how the serializes or deserializes an object. If you apply the to any member of a class, the ignores the member when serializing or deserializing an instance of the class. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + You can override the behavior caused by the by creating an object, and setting its property to `false`. You must the object to an instance of the class. Lastly, you must use the object to construct an instance of the class before you call the or methods. + + The [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) occasionally generates the when creating classes from a schema file (.xsd). This behavior occurs because value types cannot be set to `null`, but all XML data types can be. Therefore, the tool creates two fields when it encounters an XML type that maps to a value type: one to hold the value and another special field that takes the form of `fieldnameSpecified`, where the `fieldname` is replaced by the name of the field or property. Notice, however, that this special field is generated only when the schema specifies that the element has no minimum occurrence (minOccurs = "0") and that the element has no default value. The sets and checks this special field to determine whether a value has been set for the field or property. Because the special field must not be serialized, the tool applies the to it. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlIgnore` in your code instead of the longer . - - - -## Examples - The following example shows a class named `Group`, which contains a field named `Comment`. The example assigns the to the field, thereby instructing the to ignore the field when serializing or deserializing an instance of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlIgnore` in your code instead of the longer . + + + +## Examples + The following example shows a class named `Group`, which contains a field named `Comment`. The example assigns the to the field, thereby instructing the to ignore the field when serializing or deserializing an instance of the class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlIgnoreAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -153,15 +152,14 @@ Initializes a new instance of the class. - to the field, thereby instructing the to ignore the field when serializing or deserializing an instance of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp" id="Snippet1"::: + to the field, thereby instructing the to ignore the field when serializing or deserializing an instance of the class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlIgnoreAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlIncludeAttribute.xml b/xml/System.Xml.Serialization/XmlIncludeAttribute.xml index 1ae4f82d0f0..dbed8356f55 100644 --- a/xml/System.Xml.Serialization/XmlIncludeAttribute.xml +++ b/xml/System.Xml.Serialization/XmlIncludeAttribute.xml @@ -65,24 +65,24 @@ Allows the to recognize a type when it serializes or deserializes an object. - when you call the or method of the class. - - When applying the , specify the of the derived class. When the serializes objects that include both the base and the derived class, it can then recognize both object types. - - You can use the to include derived classes in service description documents that are written in the Web Services Description Language (WSDL). For example, if a method returns an , apply the to the method and specify the actual types to return. - - For more information on the WSDL, see [Web Services Description Language (WSDL) 1.1](https://www.w3.org/TR/2001/NOTE-wsdl-20010315). - - - -## Examples - The following example shows three classes, two of which inherit from the third. The example applies the to a method that returns an instance of one of the derived classes. - + when you call the or method of the class. + + When applying the , specify the of the derived class. When the serializes objects that include both the base and the derived class, it can then recognize both object types. + + You can use the to include derived classes in service description documents that are written in the Web Services Description Language (WSDL). For example, if a method returns an , apply the to the method and specify the actual types to return. + + For more information on the WSDL, see [Web Services Description Language (WSDL) 1.1](https://www.w3.org/TR/2001/NOTE-wsdl-20010315). + + + +## Examples + The following example shows three classes, two of which inherit from the third. The example applies the to a method that returns an instance of one of the derived classes. + :::code language="aspx-csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlIncludeAttribute/Overview/sourcecs.asmx"::: - + ]]> @@ -144,15 +144,14 @@ The of the object to include. Initializes a new instance of the class. - to a method that returns an instance of one of the two derived classes. The example sets the property to the type of the returned object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp" id="Snippet1"::: + to a method that returns an instance of one of the two derived classes. The example sets the property to the type of the returned object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlIncludeAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -211,15 +210,14 @@ Gets or sets the type of the object to include. The of the object to include. - to the `Employee` class. When the example creates a `Group` object, it inserts a `Manager` object into the `Employee` array. Lastly, the example serializes the `Group` object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp" id="Snippet1"::: + to the `Employee` class. When the example creates a `Group` object, it inserts a `Manager` object into the `Employee` array. Lastly, the example serializes the `Group` object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlIncludeAttribute/Type/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlNodeEventArgs.xml b/xml/System.Xml.Serialization/XmlNodeEventArgs.xml index d35e18f184b..1165792d6d7 100644 --- a/xml/System.Xml.Serialization/XmlNodeEventArgs.xml +++ b/xml/System.Xml.Serialization/XmlNodeEventArgs.xml @@ -50,22 +50,21 @@ Provides data for the event. - event can occur only when you call the method. - - - -## Examples - The following example uses the event of the to print various properties of an unknown XML node that is encountered when calling the class's method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp" id="Snippet1"::: + event can occur only when you call the method. + + + +## Examples + The following example uses the event of the to print various properties of an unknown XML node that is encountered when calling the class's method. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -118,13 +117,12 @@ Gets the line number of the unknown XML node. The line number of the unknown XML node. - @@ -174,13 +172,12 @@ Gets the position in the line of the unknown XML node. The position number of the unknown XML node. - @@ -224,20 +221,19 @@ Gets the XML local name of the XML node being deserialized. The XML local name of the node being deserialized. - property returns the local name (also known as a local part) of an XML qualified name. The property conforms to the 1999 http://www.w3.org specification `Namespaces in XML`. - - - -## Examples - The following example prints the of an unknown XML node that is encountered when calling the class's method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp" id="Snippet1"::: + property returns the local name (also known as a local part) of an XML qualified name. The property conforms to the 1999 http://www.w3.org specification `Namespaces in XML`. + + + +## Examples + The following example prints the of an unknown XML node that is encountered when calling the class's method. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/LocalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -283,15 +279,14 @@ Gets the name of the XML node being deserialized. The name of the node being deserialized. - event to occur. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp" id="Snippet1"::: + event to occur. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/Name/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -337,15 +332,14 @@ Gets the namespace URI that is associated with the XML node being deserialized. The namespace URI that is associated with the XML node being deserialized. - event to occur. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp" id="Snippet1"::: + event to occur. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/NamespaceURI/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -391,20 +385,19 @@ Gets the type of the XML node being deserialized. The that represents the XML node being deserialized. - enumeration returns a description of the node being deserialized. For example, it returns "Comment" if the node is a comment. - - - -## Examples - The following example prints a description of the unknown node that caused the event to occur. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp" id="Snippet1"::: + enumeration returns a description of the node being deserialized. For example, it returns "Comment" if the node is a comment. + + + +## Examples + The following example prints a description of the unknown node that caused the event to occur. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/NodeType/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -461,15 +454,14 @@ Gets the object being deserialized. The being deserialized. - method when the method encounters an unknown XML node. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp" id="Snippet1"::: + method when the method encounters an unknown XML node. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/ObjectBeingDeserialized/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -522,15 +514,14 @@ Gets the text of the XML node being deserialized. The text of the XML node being deserialized. - event to occur. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp" id="Snippet1"::: + event to occur. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/Text/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlNodeEventHandler.xml b/xml/System.Xml.Serialization/XmlNodeEventHandler.xml index b7bfcf39415..cbf78cafeea 100644 --- a/xml/System.Xml.Serialization/XmlNodeEventHandler.xml +++ b/xml/System.Xml.Serialization/XmlNodeEventHandler.xml @@ -60,22 +60,21 @@ An that contains the event data. Represents the method that handles the event of an . - delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - The event occurs only when you call the method. - - - -## Examples - The following example creates an , adds an event handler for the event, and deserializes an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp" id="Snippet1"::: + delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + The event occurs only when you call the method. + + + +## Examples + The following example creates an , adds an event handler for the event, and deserializes an object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventHandler/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlRootAttribute.xml b/xml/System.Xml.Serialization/XmlRootAttribute.xml index 20c54d37730..fbb46893a41 100644 --- a/xml/System.Xml.Serialization/XmlRootAttribute.xml +++ b/xml/System.Xml.Serialization/XmlRootAttribute.xml @@ -73,29 +73,28 @@ Controls XML serialization of the attribute target as an XML root element. - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - You can apply the to a class, structure, enumeration, or interface. You can also apply the attribute to the return value of an XML Web service method. - - Every XML document must have a single root element that contains all the other elements. The allows you to control how the generates the root element by setting certain properties. For example, specify the name of the generated XML element by setting the property. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + You can apply the to a class, structure, enumeration, or interface. You can also apply the attribute to the return value of an XML Web service method. + + Every XML document must have a single root element that contains all the other elements. The allows you to control how the generates the root element by setting certain properties. For example, specify the name of the generated XML element by setting the property. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlRoot` in your code instead of the longer . - - - -## Examples - The following example applies the to a class. The attribute specifies the element name, namespace, and whether the element is qualified, and whether the `xsi:nil` attribute is generated if the class is set to `null`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlRoot` in your code instead of the longer . + + + +## Examples + The following example applies the to a class. The attribute specifies the element name, namespace, and whether the element is qualified, and whether the `xsi:nil` attribute is generated if the class is set to `null`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlRootAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -160,15 +159,14 @@ Initializes a new instance of the class. - and assigns it to the property of an object. When the serializes the `MyClass` object, it uses the object to override the default root element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp" id="Snippet1"::: + and assigns it to the property of an object. When the serializes the `MyClass` object, it uses the object to override the default root element. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlRootAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -221,15 +219,14 @@ The name of the XML root element. Initializes a new instance of the class and specifies the name of the XML root element. - @@ -287,71 +284,71 @@ Gets or sets the XSD data type of the XML root element. An XSD (XML Schema Document) data type. - structures, and apply a with the property set to "base64Binary" or "hexBinary", as appropriate. For the XSD `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XSD type that is mapped to a string, apply the with its property set to the XSD type. However, this does not change the serialization format, only the schema for the member. - + structures, and apply a with the property set to "base64Binary" or "hexBinary", as appropriate. For the XSD `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XSD type that is mapped to a string, apply the with its property set to the XSD type. However, this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XSD data types. - +> The property is case-sensitive, so you must set it exactly to one of the XSD data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient than passing it as an XML attribute. - - For more information about XML data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|recurringDate|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - +> Passing binary data as an XML element is more efficient than passing it as an XML attribute. + + For more information about XML data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|recurringDate|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + ]]> @@ -408,20 +405,19 @@ Gets or sets the name of the XML element that is generated and recognized by the class's and methods, respectively. The name of the XML root element that is generated and recognized in an XML-document instance. The default is the name of the serialized class. - if you want the name of the generated XML element to differ from the class name. - - - -## Examples - The following example creates an instance of the class and sets the property to a new value. The object is then used to create an object used to override the serialization of an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp" id="Snippet1"::: + if you want the name of the generated XML element to differ from the class name. + + + +## Examples + The following example creates an instance of the class and sets the property to a new value. The object is then used to create an object used to override the serialization of an object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlRootAttribute/ElementName/xmlrootattribute_elementname.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLRootAttribute_ElementName/VB/xmlrootattribute_elementname.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLRootAttribute_ElementName/VB/xmlrootattribute_elementname.vb" id="Snippet1"::: + ]]> @@ -479,36 +475,35 @@ if the generates the attribute; otherwise, . - property is set to `true`, the `xsi:nil` attribute is generated as shown in the following XML: - -``` - - -``` - - If the property is `false`, an empty element is created as shown in the following code: - -``` - - -``` - - - -## Examples - The following example serializes a class named `Group`. The example applies the to the class, and sets the property to `false`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp" id="Snippet1"::: + + If the property is set to `true`, the `xsi:nil` attribute is generated as shown in the following XML: + +``` + + +``` + + If the property is `false`, an empty element is created as shown in the following code: + +``` + + +``` + + + +## Examples + The following example serializes a class named `Group`. The example applies the to the class, and sets the property to `false`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlRootAttribute/IsNullable/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -574,22 +569,21 @@ xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> Gets or sets the namespace for the XML root element. The namespace for the XML element. - property conforms to the World Wide Web Consortium specification named [Namespaces in XML](https://www.w3.org/TR/xml-names/). - - To create prefixed namespaces in the XML document, create an object that contains all the prefix-namespace pairs. The namespace you set for each must be contained in the object. When the generates the document, it correctly prefixes the element name for each array item. - - - -## Examples - The following example applies the to a class and sets the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp" id="Snippet1"::: + property conforms to the World Wide Web Consortium specification named [Namespaces in XML](https://www.w3.org/TR/xml-names/). + + To create prefixed namespaces in the XML document, create an object that contains all the prefix-namespace pairs. The namespace you set for each must be contained in the object. When the generates the document, it correctly prefixes the element name for each array item. + + + +## Examples + The following example applies the to a class and sets the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlRootAttribute/Namespace/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlSerializer.xml b/xml/System.Xml.Serialization/XmlSerializer.xml index eb73609a3d3..2dc892c28cd 100644 --- a/xml/System.Xml.Serialization/XmlSerializer.xml +++ b/xml/System.Xml.Serialization/XmlSerializer.xml @@ -62,7 +62,6 @@ @@ -199,7 +198,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example constructs an that serializes an object named `Widget`. The example sets various properties of the object before calling the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source5.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/VB/source.vb" id="Snippet1"::: @@ -277,7 +275,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes a class named `Group`. The serialization of the `GroupName`, `IgnoreThis` fields, and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a object is created, and for each overridden member or enumeration, a object is created with the appropriate property set and added to the object. An object is created using the object, and that object is used to create the that overrides the default serialization. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: @@ -359,7 +356,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example constructs an that serializes an object named `Widget`. The example sets various properties of the object before calling the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/VB/source.vb" id="Snippet1"::: @@ -452,7 +448,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an instance of a class that contains a public field that returns an array of objects. The `extraTypes` parameter of the constructor specifies the types of the objects that can be serialized in the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/VB/source.vb" id="Snippet1"::: @@ -539,7 +534,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an instance of a class that is defined in a DLL and to do so, overrides the public members found in the DLL. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/VB/source.vb" id="Snippet1"::: @@ -627,7 +621,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example constructs an that uses an that contains various properties of the XML root element, such as its namespace and element name. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/VB/source.vb" id="Snippet1"::: @@ -735,7 +728,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an instance of a class that is defined in a DLL and to do so, overrides the public members found in the class. The example also specifies an array of extra types, the default namespace for all XML elements, and the class to use that provides the XML root element information. The example assumes that the code at the beginning has been compiled into a DLL named `HighSchool`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/VB/source.vb" id="Snippet1"::: @@ -941,7 +933,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example calls the method to check whether an XML document can be deserialized. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/CanDeserialize/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/VB/source.vb" id="Snippet1"::: @@ -1135,7 +1126,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example deserializes an object using a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Deserialize/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/Common/simple.xml" id="Snippet1"::: @@ -1230,7 +1220,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example deserializes an object using a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Deserialize/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/VB/source.vb" id="Snippet1"::: @@ -1375,7 +1364,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example deserializes an object using an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Deserialize/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/Common/simple.xml" id="Snippet1"::: @@ -1916,7 +1904,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example uses the method to return an array of objects. The code includes three class definitions that are each used to create an array of objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/FromTypes/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/VB/source.vb" id="Snippet1"::: @@ -2272,7 +2259,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object using a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/Common/simple.xml" id="Snippet1"::: @@ -2380,7 +2366,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object using a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/Common/simple.xml" id="Snippet1"::: @@ -2538,7 +2523,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object using an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/Common/simple.xml" id="Snippet1"::: @@ -2648,7 +2632,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object with a object. The example also creates an and adds two namespaces to the object. The class that defines the serialized object is also attributed with attributes to specify the namespace for each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/VB/source.vb" id="Snippet1"::: @@ -2749,7 +2732,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object with a . The example also creates an object and adds two namespaces to the object. The class that defines the serialized object is also attributed with attributes to specify the namespace for each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/Common/simple.xml" id="Snippet1"::: @@ -2850,7 +2832,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object with an . The example also creates an and adds two namespaces to the object. Several instances of the class are applied to the class members to specify the namespace for each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source5.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/Common/simple.xml" id="Snippet1"::: @@ -3095,7 +3076,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example prints information about any unknown attributes encountered while deserializing an XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: @@ -3177,7 +3157,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: @@ -3245,7 +3224,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example prints the type of any encountered unknown node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/VB/source.vb" id="Snippet1"::: @@ -3344,7 +3322,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/XmlSerializerNamespaces.xml b/xml/System.Xml.Serialization/XmlSerializerNamespaces.xml index e14e799929b..df33e199cde 100644 --- a/xml/System.Xml.Serialization/XmlSerializerNamespaces.xml +++ b/xml/System.Xml.Serialization/XmlSerializerNamespaces.xml @@ -69,61 +69,60 @@ Contains the XML namespaces and prefixes that the uses to generate qualified names in an XML-document instance. - contains a collection of XML namespaces, each with an associated prefix. The uses an instance of the class to create qualified names in an XML document. - - XML namespaces contained by the must conform to the W3C specification named [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/). - - XML namespaces provide a way to qualify the names of XML elements and attributes in XML documents. A qualified name consists of a prefix and a local name, separated by a colon. The prefix functions only as a placeholder; it is mapped to a URI that specifies a namespace. The combination of the universally-managed URI namespace and the local name produces a name that is guaranteed to be universally unique. - - To create qualified names in an XML document: - -1. Create an instance. - -2. each prefix and namespace pair that you want to the instance. - -3. Apply the appropriate.NET attribute to each property or class that the serializes into an XML document. The available attributes are: - -- - -- - -- - -- - -- - -- - -1. Set the `Namespace` property of each attribute to one of the namespace values from the object. - -2. Pass the to the method of the . - + contains a collection of XML namespaces, each with an associated prefix. The uses an instance of the class to create qualified names in an XML document. + + XML namespaces contained by the must conform to the W3C specification named [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/). + + XML namespaces provide a way to qualify the names of XML elements and attributes in XML documents. A qualified name consists of a prefix and a local name, separated by a colon. The prefix functions only as a placeholder; it is mapped to a URI that specifies a namespace. The combination of the universally-managed URI namespace and the local name produces a name that is guaranteed to be universally unique. + + To create qualified names in an XML document: + +1. Create an instance. + +2. each prefix and namespace pair that you want to the instance. + +3. Apply the appropriate.NET attribute to each property or class that the serializes into an XML document. The available attributes are: + +- + +- + +- + +- + +- + +- + +1. Set the `Namespace` property of each attribute to one of the namespace values from the object. + +2. Pass the to the method of the . + > [!NOTE] -> The creation of an empty namespace and prefix pair is not supported. That is, you cannot create a pair using the following code: - -```csharp -XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); -ns.Add("", ""); -``` - -```vb -Dim ns As XmlSerializerNamespaces ns = New XmlSerializerNamespaces() -ns.Add("", "") -``` +> The creation of an empty namespace and prefix pair is not supported. That is, you cannot create a pair using the following code: + +```csharp +XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); +ns.Add("", ""); +``` + +```vb +Dim ns As XmlSerializerNamespaces ns = New XmlSerializerNamespaces() +ns.Add("", "") +``` + + + +## Examples + The following example creates an object, and adds two prefix and namespace pairs to it. The example then passes the to the method, which serializes a `Books` object into an XML document. Using the object, the method qualifies each XML element and attribute with one of the two namespaces. - - -## Examples - The following example creates an object, and adds two prefix and namespace pairs to it. The example then passes the to the method, which serializes a `Books` object into an XML document. Using the object, the method qualifies each XML element and attribute with one of the two namespaces. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializerNamespaces/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -191,15 +190,14 @@ ns.Add("", "") Initializes a new instance of the class. - class, and adds a prefix and namespace pair to the object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp" id="Snippet1"::: + class, and adds a prefix and namespace pair to the object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializerNamespaces/.ctor/xmlserializernamespaces_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/VB/xmlserializernamespaces_constructor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/VB/xmlserializernamespaces_constructor.vb" id="Snippet1"::: + ]]> @@ -250,15 +248,14 @@ ns.Add("", "") An instance of the containing the namespace and prefix pairs. Initializes a new instance of the class, using the specified instance of containing the collection of prefix and namespace pairs. - objects, and creates a new instance from them. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp" id="Snippet1"::: + objects, and creates a new instance from them. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializerNamespaces/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -370,22 +367,21 @@ ns.Add("", "") An XML namespace. Adds a prefix and namespace pair to an object. - to qualify the element and attribute names in an XML document, you must the prefix and namespace pairs to an object. - - Any namespaces that you add must conform to the W3C [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/) specification. - - - -## Examples - The following example creates an object, and adds three prefix and namespace pairs to it by calling the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp" id="Snippet1"::: + to qualify the element and attribute names in an XML document, you must the prefix and namespace pairs to an object. + + Any namespaces that you add must conform to the W3C [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/) specification. + + + +## Examples + The following example creates an object, and adds three prefix and namespace pairs to it by calling the method. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializerNamespaces/Add/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -485,15 +481,14 @@ ns.Add("", "") Gets the array of prefix and namespace pairs in an object. An array of objects that are used as qualified names in an XML document. - and in an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp" id="Snippet1"::: + and in an object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializerNamespaces/ToArray/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlTextAttribute.xml b/xml/System.Xml.Serialization/XmlTextAttribute.xml index fb2114e1401..3ffb7071087 100644 --- a/xml/System.Xml.Serialization/XmlTextAttribute.xml +++ b/xml/System.Xml.Serialization/XmlTextAttribute.xml @@ -73,54 +73,53 @@ Indicates to the that the member must be treated as XML text when the class that contains it is serialized or deserialized. - belongs to a family of attributes that controls how the serializes and deserializes an object (through its and methods). For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - Only one instance of the class can be applied in a class. - - You can apply the to public fields and public read/write properties that return primitive and enumeration types. - - You can apply the to a field or property that returns an array of strings. You can also apply the attribute to an array of type but you must set the property to string. In that case, any strings inserted into the array are serialized as XML text. - - The can also be applied to a field that returns an or an array of objects. - - By default, the serializes a class member as an XML element. However, if you apply the to a member, the translates its value into XML text. This means that the value is encoded into the content of an XML element. - - The [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) occasionally generates the when creating classes from an XML Schema definition (XSD) file. This occurs when the schema contains a `complexType` with mixed content; in that case, the corresponding class contains a member that returns a string array to which the is applied. For example, when the `Xml Schema Definition` tool processes this schema: - -```xml - - - - - - - - - - -``` - - the following class is generated (extra spaces and remarks have been removed): - + belongs to a family of attributes that controls how the serializes and deserializes an object (through its and methods). For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + Only one instance of the class can be applied in a class. + + You can apply the to public fields and public read/write properties that return primitive and enumeration types. + + You can apply the to a field or property that returns an array of strings. You can also apply the attribute to an array of type but you must set the property to string. In that case, any strings inserted into the array are serialized as XML text. + + The can also be applied to a field that returns an or an array of objects. + + By default, the serializes a class member as an XML element. However, if you apply the to a member, the translates its value into XML text. This means that the value is encoded into the content of an XML element. + + The [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) occasionally generates the when creating classes from an XML Schema definition (XSD) file. This occurs when the schema contains a `complexType` with mixed content; in that case, the corresponding class contains a member that returns a string array to which the is applied. For example, when the `Xml Schema Definition` tool processes this schema: + +```xml + + + + + + + + + + +``` + + the following class is generated (extra spaces and remarks have been removed): + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/Overview/source1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTextAttribute/vb/source.vb" id="Snippet0"::: - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTextAttribute/vb/source.vb" id="Snippet0"::: + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlText` in your code instead of the longer . - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlText` in your code instead of the longer . + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -191,20 +190,19 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema"> Initializes a new instance of the class. - serializes a public field or public read/write property by creating an , and setting its property to an . For more details, see the class. - - - -## Examples - The following example serializes a class that contains a public field, named `Comment`. The example applies an to the field, thereby overriding its serialization as an XML element, and instead serializing it as XML text. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp" id="Snippet1"::: + serializes a public field or public read/write property by creating an , and setting its property to an . For more details, see the class. + + + +## Examples + The following example serializes a class that contains a public field, named `Comment`. The example applies an to the field, thereby overriding its serialization as an XML element, and instead serializing it as XML text. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -262,18 +260,17 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema"> The of the member to be serialized. Initializes a new instance of the class. - serializes a public field or public read/write property by creating an , and setting its property to an . For more details, see the class. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp" id="Snippet1"::: + serializes a public field or public read/write property by creating an , and setting its property to an . For more details, see the class. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -334,81 +331,80 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema"> Gets or sets the XML Schema definition language (XSD) data type of the text generated by the . An XML Schema (XSD) data type. - property to an XML Schema simple data type affects the format of the generated XML. For example, setting the property to "date" causes the generated text to be formatted in the general date style, for example: 2001-08-31. By contrast, setting the property to "dateTime" results in a specific instant as defined by the International Organization for Standardization document 8601, "Representations of Dates and Times", for example: 2001-08-15T06:59:11.0508456-07:00. - - The effect of setting the property can also be seen when using the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) to generate the XML Schema for a compiled file. For more information on using the tool, see [The XML Schema Definition Tool and XML Serialization](/dotnet/standard/serialization/the-xml-schema-definition-tool-and-xml-serialization). - - The following table lists the XML Schema simple data types with their .NET equivalents. - - For the XML Schema `base64Binary` and `hexBinary` data types, use an array of structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema data type. Note that this does not change the serialization format, only the schema for the member. - + property to an XML Schema simple data type affects the format of the generated XML. For example, setting the property to "date" causes the generated text to be formatted in the general date style, for example: 2001-08-31. By contrast, setting the property to "dateTime" results in a specific instant as defined by the International Organization for Standardization document 8601, "Representations of Dates and Times", for example: 2001-08-15T06:59:11.0508456-07:00. + + The effect of setting the property can also be seen when using the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) to generate the XML Schema for a compiled file. For more information on using the tool, see [The XML Schema Definition Tool and XML Serialization](/dotnet/standard/serialization/the-xml-schema-definition-tool-and-xml-serialization). + + The following table lists the XML Schema simple data types with their .NET equivalents. + + For the XML Schema `base64Binary` and `hexBinary` data types, use an array of structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema data type. Note that this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. - +> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient than passing it as an XML attribute. - - For more information about XML Schema data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient than passing it as an XML attribute. + + For more information about XML Schema data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> The XML Schema data type you have specified cannot be mapped to the .NET data type. @@ -472,22 +468,21 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema"> Gets or sets the type of the member. The of the member. - property can only be set to primitive types and enumerations. - - The can also be applied to a field that returns an or an array of objects. - - You can apply the to a field or property that returns an array of strings. You can also apply the attribute to an array of type but you must set the property to string. In that case, any strings inserted into the array are serialized as XML text. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp" id="Snippet1"::: + property can only be set to primitive types and enumerations. + + The can also be applied to a field that returns an or an array of objects. + + You can apply the to a field or property that returns an array of strings. You can also apply the attribute to an array of type but you must set the property to string. In that case, any strings inserted into the array are serialized as XML text. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlTypeAttribute.xml b/xml/System.Xml.Serialization/XmlTypeAttribute.xml index 7d983d2066e..6c0bcc6a31d 100644 --- a/xml/System.Xml.Serialization/XmlTypeAttribute.xml +++ b/xml/System.Xml.Serialization/XmlTypeAttribute.xml @@ -61,32 +61,31 @@ Controls the XML schema that is generated when the attribute target is serialized by the . - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - You can apply the to a class, structure, enumeration, or interface declaration. - - Apply the to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + You can apply the to a class, structure, enumeration, or interface declaration. + + Apply the to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. + > [!NOTE] -> If you set the property to `false`, the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) does not include the type in the schema. By default, for each public class, the XSD tool generates a `complexType` and an element of that type. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - +> If you set the property to `false`, the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) does not include the type in the schema. By default, for each public class, the XSD tool generates a `complexType` and an element of that type. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlType` in your code instead of the longer . - - - -## Examples - The following example shows two classes to which the has been applied. +> You can use the word `XmlType` in your code instead of the longer . + + + +## Examples + The following example shows two classes to which the has been applied. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -148,15 +147,14 @@ Initializes a new instance of the class. - class that are used to override the serialization of the two classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp" id="Snippet2"::: + class that are used to override the serialization of the two classes. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/.ctor/xmltypeattribute1_2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLTypeAttribute1_2/VB/xmltypeattribute1_2.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLTypeAttribute1_2/VB/xmltypeattribute1_2.vb" id="Snippet2"::: + ]]> @@ -205,20 +203,19 @@ The name of the XML type that the generates when it serializes the class instance (and recognizes when it deserializes the class instance). Initializes a new instance of the class and specifies the name of the XML type. - to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. - - - -## Examples - The following example creates two instances of the class that are used to override the serialization of the two classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp" id="Snippet2"::: + to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. + + + +## Examples + The following example creates two instances of the class that are used to override the serialization of the two classes. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/.ctor/xmltypeattribute1_2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLTypeAttribute1_2/VB/xmltypeattribute1_2.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLTypeAttribute1_2/VB/xmltypeattribute1_2.vb" id="Snippet2"::: + ]]> @@ -332,20 +329,19 @@ to include the type in XML schema documents; otherwise, . - to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the XML Schema Definition tool (XSD.exe). The tool writes the schema, including the type definition. - - - -## Examples - The following example applies the to the `ExtraneousInfo` class, setting the property to `false`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp" id="Snippet1"::: + to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the XML Schema Definition tool (XSD.exe). The tool writes the schema, including the type definition. + + + +## Examples + The following example applies the to the `ExtraneousInfo` class, setting the property to `false`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/IncludeInSchema/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -404,15 +400,14 @@ Gets or sets the namespace of the XML type. The namespace of the XML type. - to a class while setting the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp" id="Snippet1"::: + to a class while setting the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/Namespace/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -470,20 +465,19 @@ Gets or sets the name of the XML type. The name of the XML type. - to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. - - - -## Examples - The following example applies the to the `Person` and `Job` classes. If you compile the class and pass the resulting executable file to the XML Schema Definition tool, the schema is displayed in the Output section. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp" id="Snippet1"::: + to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. + + + +## Examples + The following example applies the to the `Person` and `Job` classes. If you compile the class and pass the resulting executable file to the XML Schema Definition tool, the schema is displayed in the Output section. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/TypeName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlTypeMapping.xml b/xml/System.Xml.Serialization/XmlTypeMapping.xml index ce399cb78f6..5d62c8a89f5 100644 --- a/xml/System.Xml.Serialization/XmlTypeMapping.xml +++ b/xml/System.Xml.Serialization/XmlTypeMapping.xml @@ -54,20 +54,19 @@ Contains a mapping of one type to another. - class is used to serialize an object as encoded SOAP XML. The resulting XML conforms to section 5 of the [World Wide Web Consortium](https://www.w3.org) document, "Simple Object Access Protocol (SOAP) 1.1". Create an by calling the method of the class. Use the to construct an instance of the class. To control the serialization, use one of the attributes listed in [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - - -## Examples - The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + class is used to serialize an object as encoded SOAP XML. The resulting XML conforms to section 5 of the [World Wide Web Consortium](https://www.w3.org) document, "Simple Object Access Protocol (SOAP) 1.1". Create an by calling the method of the class. Use the to construct an instance of the class. To control the serialization, use one of the attributes listed in [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + + +## Examples + The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> Introducing XML Serialization @@ -135,12 +134,12 @@ Gets the XML namespace of the mapped object. The XML namespace of the mapped object. The default is an empty string (""). - to the class, and set the property to a new value. - + ]]> @@ -187,13 +186,12 @@ To set a namespace name of an object, apply a The fully qualified type name that includes the namespace (or namespaces) and type. The fully qualified type name. - @@ -240,20 +238,19 @@ To set a namespace name of an object, apply a Gets the type name of the mapped object. The type name of the mapped object. - property. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp" id="Snippet1"::: + property. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeMapping/TypeFullName/mapping.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: + ]]> @@ -306,18 +303,17 @@ To set a namespace name of an object, apply a Gets the XML element name of the mapped object. The XML element name of the mapped object. The default is the class name of the object. - to the class, and set the property to a new value. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp" id="Snippet1"::: + to the class, and set the property to a new value. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeMapping/TypeFullName/mapping.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: + ]]> @@ -370,18 +366,17 @@ To set a namespace name of an object, apply a Gets the XML namespace of the mapped object. The XML namespace of the mapped object. The default is an empty string (""). - to the class, and set the property to a new value. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp" id="Snippet1"::: + to the class, and set the property to a new value. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeMapping/TypeFullName/mapping.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.XPath/XPathNavigator.xml b/xml/System.Xml.XPath/XPathNavigator.xml index f6d403470ce..2e1fb8ff515 100644 --- a/xml/System.Xml.XPath/XPathNavigator.xml +++ b/xml/System.Xml.XPath/XPathNavigator.xml @@ -281,7 +281,6 @@ ## Examples In the following example, a new `pages` child element is appended to the list of child elements of the first `book` element in the `contosoBooks.xml` file using the object returned from the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet1"::: @@ -385,7 +384,6 @@ ## Examples In the following example, a new `pages` child element is appended to the list of child elements of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet2"::: @@ -489,7 +487,6 @@ ## Examples In the following example, a new `pages` child element is appended to the list of child elements of the first `book` element in the `contosoBooks.xml` file using the object specified. The `http://www.contoso.com/books` namespace is specified so that the new child element is appended using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet3"::: @@ -596,7 +593,6 @@ ## Examples In the following example, a new `pages` child element is appended to the list of child elements of the first `book` element in the `contosoBooks.xml` file using the node contained in the specified. The `http://www.contoso.com/books` namespace is specified so that the new child element is appended using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet4"::: @@ -723,7 +719,6 @@ navigator.AppendChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navig ## Examples In the following example, a new `pages` child element is appended to the list of child elements of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet5"::: @@ -879,7 +874,6 @@ navigator.AppendChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navig ## Examples The following example uses the property to display the values of the and classes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet1"::: @@ -1043,7 +1037,6 @@ navigator.AppendChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navig ## Examples The following example gets all book titles authored by Herman Melville. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet6"::: @@ -1312,7 +1305,6 @@ editor.CreateAttribute(navigator.Prefix, "attributeName", LookupNamespace(naviga ## Examples In the following example, a new `discount` attribute is created on the `price` child element of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet7"::: @@ -1418,7 +1410,6 @@ editor.CreateAttribute(navigator.Prefix, "attributeName", LookupNamespace(naviga ## Examples In the following example, new `discount` and `currency` attributes are created on the `price` child element of the first `book` element in the `contosoBooks.xml` file using the object returned from the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet8"::: @@ -1575,7 +1566,6 @@ editor.CreateAttribute(navigator.Prefix, "attributeName", LookupNamespace(naviga ## Examples In the following example, the first and second `book` elements of the `contosoBooks.xml` file are deleted using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet52"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet52"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet52"::: @@ -1680,7 +1670,6 @@ editor.CreateAttribute(navigator.Prefix, "attributeName", LookupNamespace(naviga ## Examples In the following example the `price` element of the first `book` element of the `contosoBooks.xml` file is deleted using the method. The position of the object after the `price` element is deleted is on the parent `book` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet9"::: @@ -1796,7 +1785,6 @@ nav.Evaluate("Price/text()*10"); ## Examples The following example evaluates an XPath expression and returns a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet10"::: @@ -1911,7 +1899,6 @@ nav.Evaluate(expr); ## Examples The following example evaluates an and returns a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet11"::: @@ -2030,7 +2017,6 @@ nav.Evaluate(expr); ## Examples The following example evaluates an XPath expression and returns a using the object specified to resolve namespace prefixes in the XPath expression. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet12"::: @@ -2148,7 +2134,6 @@ nav.Evaluate(expr); ## Examples The following example evaluates an and returns a using the node of the as the context node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet13"::: @@ -2562,7 +2547,6 @@ nav.Evaluate(expr); ## Examples The following example uses the property to display the contents of the first `book` element in the `contosoBooks.xml` file and its child nodes in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet2"::: @@ -2670,7 +2654,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted after the `price` child element of the first `book` element in the `contosoBooks.xml` file using the object returned by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet14"::: @@ -2772,7 +2755,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted after the `price` child element of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet15"::: @@ -2876,7 +2858,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted after the `price` child element of the first `book` element in the `contosoBooks.xml` file using the object specified. The `http://www.contoso.com/books` namespace is specified so that the new sibling element is inserted using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet16"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet16"::: @@ -2981,7 +2962,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted after the `price` child element of the first `book` element in the `contosoBooks.xml` file using the node contained in the object specified. The `http://www.contoso.com/books` namespace is specified so that the new sibling element is inserted using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet17"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet17"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet17"::: @@ -3091,7 +3071,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted before the `price` child element of the first `book` element in the `contosoBooks.xml` file using the object returned by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet18"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet18"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet18"::: @@ -3193,7 +3172,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted before the `price` child element of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet19"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet19"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet19"::: @@ -3297,7 +3275,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted before the `price` child element of the first `book` element in the `contosoBooks.xml` file using the object specified. The `http://www.contoso.com/books` namespace is specified so that the new sibling element is inserted using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet20"::: @@ -3402,7 +3379,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted before the `price` child element of the first `book` element in the `contosoBooks.xml` file using the node contained in the object specified. The `http://www.contoso.com/books` namespace is specified so that the new sibling element is inserted using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet21"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet21"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet21"::: @@ -3527,7 +3503,6 @@ navigator.InsertElementAfter(navigator.Prefix, "pages", LookupNamespaceURI(navig ## Examples In the following example a new `pages` element is inserted after the `price` child element of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet22"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet22"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet22"::: @@ -3651,7 +3626,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example a new `pages` element is inserted before the `price` child element of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet23"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet23"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet23"::: @@ -3997,7 +3971,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about and nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -4310,7 +4283,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example displays the titles of all novels. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet24"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet24"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet24"::: @@ -4725,7 +4697,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example uses the and methods to display all the attributes for each book in the `books.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet49"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet49"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet49"::: @@ -5070,7 +5041,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, the is moved from the root of the `contosoBooks.xml` file to the following `bookstore` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet25"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet25"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet25"::: @@ -5174,7 +5144,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, the is moved from the root of the `contosoBooks.xml` file to the first `price` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet26"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet26"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet26"::: @@ -5282,7 +5251,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, the is moved from the root of the `contosoBooks.xml` file to the following `price` element. A clone of the object is made using the method. The cloned , positioned on the `price` element, will be used as a boundary. Changes in the position of the cloned do not affect the original . The original is moved back to the root of the `contosoBooks.xml` file using the method. The title and first and last name of the author are retrieved using the method and an of . The method will return true until the `price` element boundary is reached. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet27"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet27"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet27"::: @@ -5397,7 +5365,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, the is moved from the root of the `contosoBooks.xml` file to the following `book` element. A clone of the object is made using the method and is moved from the `book` element to the following `first-name` element. The cloned , positioned on the `first-name` element, will be used as a boundary. Changes in the position of the cloned do not affect the original . The original then attempts to move to the following `price` element using the method with the boundary passed as a parameter. This move fails because the following `price` element is beyond the boundary. The original then attempts to move to the following `title` element which is before the boundary using the same method and succeeds. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet28"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet28"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet28"::: @@ -5626,7 +5593,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about element and text nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -5843,7 +5809,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example uses the and methods to display all the attributes for each book in the `books.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet49"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet49"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet49"::: @@ -6280,7 +6245,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about and nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -6378,7 +6342,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about and nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -6530,7 +6493,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example illustrates the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet3"::: @@ -6617,7 +6579,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about and nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -6716,7 +6677,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example uses the property to display the contents of the first `book` element in the `contosoBooks.xml` file, its child nodes, and its opening and closing tags in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet4"::: @@ -6808,7 +6768,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about and nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -6917,7 +6876,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, a new `pages` child element is prepended to the beginning of the list of child elements of the first `book` element in the `contosoBooks.xml` file using the object returned from the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet30"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet30"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet30"::: @@ -7021,7 +6979,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, a new `pages` child element is prepended to the beginning of the list of child elements of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet31"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet31"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet31"::: @@ -7127,7 +7084,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, a new `pages` child element is prepended to the beginning of the list of child elements of the first `book` element in the `contosoBooks.xml` file using the object specified. The `http://www.contoso.com/books` namespace is specified so that the new child element is prepended using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet32"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet32"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet32"::: @@ -7234,7 +7190,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, a new `pages` child element is prepended to the beginning of the list of child elements of the first `book` element in the `contosoBooks.xml` file using the node contained in the object specified. The `http://www.contoso.com/books` namespace is specified so that the new child element is prepended using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet33"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet33"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet33"::: @@ -7361,7 +7316,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, a new `pages` child element is prepended to the beginning of the list of child elements of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet34"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet34"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet34"::: @@ -7467,7 +7421,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example illustrates using the method on the first `book` element of the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet35"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet35"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet35"::: @@ -7566,7 +7519,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, the first and second `book` elements of the `contosoBooks.xml` file are replaced with a new empty `book` element using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet53"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet53"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet53"::: @@ -7680,7 +7632,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example the `price` element in the `contosoBooks.xml` file is replaced by a new `pages` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet36"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet36"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet36"::: @@ -7786,7 +7737,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example the `price` element in the `contosoBooks.xml` file is replaced by a new `pages` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet37"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet37"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet37"::: @@ -7893,7 +7843,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example the `price` element in the `contosoBooks.xml` file is replaced by a new `pages` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet38"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet38"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet38"::: @@ -8079,7 +8028,6 @@ while (iterator.MoveNext()) ## Examples The following example uses the method to select a node set. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet39"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet39"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet39"::: @@ -8246,7 +8194,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example uses the method to select a node set. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet40"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet40"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet40"::: @@ -8353,7 +8300,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example illustrates selecting a node set using the method with the object specified to resolve namespace prefixes in the XPath expression. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet41"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet41"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet41"::: @@ -8532,7 +8478,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example illustrates selecting ancestor, child, and descendant nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet42"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet42"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet42"::: @@ -8942,7 +8887,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example selects a single node from the based on the XPath query specified. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet43"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet43"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet43"::: @@ -9046,7 +8990,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example selects a single node from the based on the XPath query contained in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet44"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet44"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet44"::: @@ -9156,7 +9099,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example selects a single node from the object based on the XPath query specified and uses the object specified to resolve namespace prefixes in the XPath query. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet45"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet45"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet45"::: @@ -9254,7 +9196,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples In the following example, the method is used to update all `price` elements in the `contosoBooks.xml` file using the object to resolve namespace prefixes in the XPath expression. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet46"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet46"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet46"::: @@ -9355,7 +9296,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples In the following example, the method is used to update all `price` elements in the `contosoBooks.xml` file using the object to resolve namespace prefixes in the XPath expression. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet47"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet47"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet47"::: @@ -9808,7 +9748,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples In the following example, the value of each element in the `valueas.xml` file is returned using the , , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet5"::: @@ -10123,7 +10062,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples In the following example, the `contosoBooks.xml` XML file and `contosoBooks.xsd` XML Schema definition language (XSD) schema are used to create an object. The typed value of the `price` element is displayed using the property and then returned as a string using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet6"::: @@ -10268,7 +10206,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example illustrates using the method on the first `book` element of the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet48"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet48"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet48"::: diff --git a/xml/System.Xml.XPath/XPathNodeIterator.xml b/xml/System.Xml.XPath/XPathNodeIterator.xml index f3505445f6b..292a6b1eed5 100644 --- a/xml/System.Xml.XPath/XPathNodeIterator.xml +++ b/xml/System.Xml.XPath/XPathNodeIterator.xml @@ -81,82 +81,79 @@ Provides an iterator over a selected set of nodes. - object returned by the class is not positioned on the first node in a selected set of nodes. A call to the method of the class must be made to position the object on the first node in the selected set of nodes. - - When using the , if you edit the current node or any of its ancestors, your current position is lost. If you want to edit a number of nodes that you have selected, create a array, copy all of the nodes from the into the array, then iterate through the array and modify the nodes. - - There are two ways to iterate over an collection by using the class. - - One way is to use the method and then call to get the current instance, as in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet55"::: + object returned by the class is not positioned on the first node in a selected set of nodes. A call to the method of the class must be made to position the object on the first node in the selected set of nodes. + + When using the , if you edit the current node or any of its ancestors, your current position is lost. If you want to edit a number of nodes that you have selected, create a array, copy all of the nodes from the into the array, then iterate through the array and modify the nodes. + + There are two ways to iterate over an collection by using the class. + + One way is to use the method and then call to get the current instance, as in the following example: + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet55"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: - - Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: + + Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet56"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet56"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: - - You should either use and or use . Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. - - - -## Examples - The following example uses the method of the class to select a node set using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet39"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: + + You should either use and or use . Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. + + + +## Examples + The following example uses the method of the class to select a node set using the class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet39"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet39"::: - - The example takes the `books.xml` file as input. - -```xml - - - - - The Autobiography of Benjamin Franklin - - Benjamin - Franklin - - 8.99 - - - The Confidence Man - - Herman - Melville - - 11.99 - - - The Gorgias - - Plato - - 9.99 - - - -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet39"::: + + The example takes the `books.xml` file as input. + +```xml + + + + + The Autobiography of Benjamin Franklin + + Benjamin + Franklin + + 8.99 + + + The Confidence Man + + Herman + Melville + + 11.99 + + + The Gorgias + + Plato + + 9.99 + + + +``` + ]]> - When you inherit from the class, you must override the following members: - -- - -- - -- - + When you inherit from the class, you must override the following members: + +- + +- + +- + - @@ -200,11 +197,11 @@ Initializes a new instance of the class. - @@ -253,11 +250,11 @@ When overridden in a derived class, returns a clone of this object. A new object clone of this object. - object is positioned at the same node in the node set if calls have been made to the method. The cloned object is not affected by subsequent changes to this object. - + object is positioned at the same node in the node set if calls have been made to the method. The cloned object is not affected by subsequent changes to this object. + ]]> @@ -306,11 +303,11 @@ Gets the index of the last node in the selected set of nodes. The index of the last node in the selected set of nodes, or 0 if there are no selected nodes. - property does not affect the position of the . - + property does not affect the position of the . + ]]> @@ -365,59 +362,58 @@ When overridden in a derived class, gets the object for this , positioned on the current context node. An object positioned on the context node from which the node set was selected. The method must be called to move the to the first node in the selected set. - object to obtain information on the current node. However, the returned object should not be modified. The returned object cannot be moved away from the selected node set. - - Alternatively, you can clone the object using the method of the class. The cloned object can then be moved away from the selected node set. This method of cloning the object might affect the performance of the XPath query. - - If the , , and methods result in no nodes being selected, the property might not be pointing to the context node. - - To test whether nodes have been selected, use the property as shown in the following example. - - - -## Examples - The following example gets all book titles authored by Herman Melville using the property of the object and the method of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet6"::: + object to obtain information on the current node. However, the returned object should not be modified. The returned object cannot be moved away from the selected node set. + + Alternatively, you can clone the object using the method of the class. The cloned object can then be moved away from the selected node set. This method of cloning the object might affect the performance of the XPath query. + + If the , , and methods result in no nodes being selected, the property might not be pointing to the context node. + + To test whether nodes have been selected, use the property as shown in the following example. + + + +## Examples + The following example gets all book titles authored by Herman Melville using the property of the object and the method of the class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet6"::: - - The example takes the `contosoBooks.xml` file as input. - -```xml - - - - - The Autobiography of Benjamin Franklin - - Benjamin - Franklin - - 8.99 - - - The Confidence Man - - Herman - Melville - - 11.99 - - - The Gorgias - - Plato - - 9.99 - - - -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet6"::: + + The example takes the `contosoBooks.xml` file as input. + +```xml + + + + + The Autobiography of Benjamin Franklin + + Benjamin + Franklin + + 8.99 + + + The Confidence Man + + Herman + Melville + + 11.99 + + + The Gorgias + + Plato + + 9.99 + + + +``` + ]]> @@ -471,11 +467,11 @@ When overridden in a derived class, gets the index of the current position in the selected set of nodes. The index of the current position. - @@ -526,27 +522,25 @@ Returns an object to iterate through the selected node set. An object to iterate through the selected node set. - object. - - There are two ways to iterate over an collection by using the class. - - One way is to use the method and then call to get the current instance, as in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet55"::: + object. + + There are two ways to iterate over an collection by using the class. + + One way is to use the method and then call to get the current instance, as in the following example: + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet55"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: - - Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet56"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: + + Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet56"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: - - You should either use the method and or use the method. Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: + + You should either use the method and or use the method. Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. + ]]> @@ -597,69 +591,66 @@ if the object moved to the next node; if there are no more selected nodes. - object is positioned on the first node in the selected node set only after the initial call to the method. The node set is created in document order. Therefore, calling the method moves to the next node in document order. - - There are two ways to iterate over an collection by using the class. - - One way is to use the method and then call to get the current instance, as in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet55"::: + object is positioned on the first node in the selected node set only after the initial call to the method. The node set is created in document order. Therefore, calling the method moves to the next node in document order. + + There are two ways to iterate over an collection by using the class. + + One way is to use the method and then call to get the current instance, as in the following example: + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet55"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: - - Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet56"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: + + Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet56"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: - - You should either use the method and or use the method. Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. - - - -## Examples - The following example uses the method of the class to select a node set using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet39"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: + + You should either use the method and or use the method. Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. + + + +## Examples + The following example uses the method of the class to select a node set using the class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet39"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet39"::: - - The example takes the `books.xml` file as input. - -```xml - - - - - The Autobiography of Benjamin Franklin - - Benjamin - Franklin - - 8.99 - - - The Confidence Man - - Herman - Melville - - 11.99 - - - The Gorgias - - Plato - - 9.99 - - - -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet39"::: + + The example takes the `books.xml` file as input. + +```xml + + + + + The Autobiography of Benjamin Franklin + + Benjamin + Franklin + + 8.99 + + + The Confidence Man + + Herman + Melville + + 11.99 + + + The Gorgias + + Plato + + 9.99 + + + +``` + ]]> @@ -717,11 +708,11 @@ Creates a new object that is a copy of the current instance. A new object that is a copy of this instance. - instance is cast to an interface. - + instance is cast to an interface. + ]]> diff --git a/xml/System.Xml.Xsl/XslTransform.xml b/xml/System.Xml.Xsl/XslTransform.xml index 877eebc7a3e..399e04611b6 100644 --- a/xml/System.Xml.Xsl/XslTransform.xml +++ b/xml/System.Xml.Xsl/XslTransform.xml @@ -283,7 +283,6 @@ ## Examples The following example transforms an XML document into an HTML document. It displays the ISBN, title, and price for each book in a table. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/VB/source.vb" id="Snippet1"::: @@ -376,7 +375,6 @@ ## Examples The following example transforms an XML file sorting all the books by title. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTransform.Load3/CPP/trans3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/trans3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load3/VB/trans3.vb" id="Snippet1"::: @@ -969,7 +967,6 @@ ## Examples The following example performs an XSLT transformation where `xsltReader` is an containing a style sheet and `secureURL` is a trusted URL that can be used to create . The method is used to create , which is applied to the style sheet. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTransform.Load4/CPP/trans_ev.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/trans_ev.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load4/VB/trans_ev.vb" id="Snippet1"::: @@ -1228,7 +1225,6 @@ ## Examples The following example transforms the `books.xml` file using the `output.xsl` style sheet and outputs the results to the `books.html` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/xsltransform.transform3/CPP/trans_snip2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/trans_snip2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/xsltransform.transform3/VB/trans_snip2.vb" id="Snippet1"::: @@ -1534,7 +1530,6 @@ Root node is book. ## Examples The following example performs an XSLT transformation and outputs to a file. An with default credentials is used resolve an external resources. See for details. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTRansform.Transform7/CPP/trans_snip4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/trans_snip4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTRansform.Transform7/VB/trans_snip4.vb" id="Snippet1"::: @@ -1945,7 +1940,6 @@ Root node is book. ## Examples The following example transforms an XML document and outputs the results to an `XmlReader`. An with the necessary credentials is used to process any XSLT `document()` functions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTransform.Transform4/CPP/trans_snip3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/trans_snip3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform4/VB/trans_snip3.vb" id="Snippet1"::: @@ -2859,7 +2853,6 @@ Root node is book. ## Examples The following example transforms an XML document into an HTML document. It displays the ISBN, title, and price for each book in a table. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/VB/source.vb" id="Snippet1"::: @@ -3157,7 +3150,6 @@ Root node is book. ## Examples The following example loads and edits an XML document before performing an XSLT transform. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTransform.Transform2/CPP/trans_snip.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/CreateNavigator/trans_snip.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform2/VB/trans_snip.vb" id="Snippet1"::: diff --git a/xml/System.Xml/IHasXmlNode.xml b/xml/System.Xml/IHasXmlNode.xml index 041fc598cff..bd3eaffd31d 100644 --- a/xml/System.Xml/IHasXmlNode.xml +++ b/xml/System.Xml/IHasXmlNode.xml @@ -42,24 +42,23 @@ Enables a class to return an from the current context or position. - from the current context or position. It is implemented by objects that operate over classes that have nodes. For example, if the `XPathNavigator` object is created by an , you can use the method to return the `XmlNode` representing the current position of the navigator. + + + +## Examples + The following example uses the `GetNode` method to retrieve and modify the selected node. -## Remarks - The `IHasXmlNode` interface provides an interface that enables a class to return an from the current context or position. It is implemented by objects that operate over classes that have nodes. For example, if the `XPathNavigator` object is created by an , you can use the method to return the `XmlNode` representing the current position of the navigator. - - - -## Examples - The following example uses the `GetNode` method to retrieve and modify the selected node. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/IHasXmlNode.GetNode/CPP/hasxmlnode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/IHasXmlNode/Overview/hasxmlnode.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/IHasXmlNode.GetNode/VB/hasxmlnode.vb" id="Snippet1"::: - - The example uses the file `books.xml` as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/IHasXmlNode.GetNode/XML/books.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/IHasXmlNode.GetNode/VB/hasxmlnode.vb" id="Snippet1"::: + + The example uses the file `books.xml` as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/IHasXmlNode.GetNode/XML/books.xml" id="Snippet2"::: + ]]> @@ -104,20 +103,20 @@ Returns the for the current position. The for the current position. - is currently positioned on. - -```csharp -XmlDocument doc = new XmlDocument(); -doc.Load("books.xml"); -XPathNavigator nav = doc.CreateNavigator(); -XmlNode node = ((IHasXmlNode)nav).GetNode(); -Console.WriteLine(node.LocalName); -//You can edit the returned XmlNode. -``` - + is currently positioned on. + +```csharp +XmlDocument doc = new XmlDocument(); +doc.Load("books.xml"); +XPathNavigator nav = doc.CreateNavigator(); +XmlNode node = ((IHasXmlNode)nav).GetNode(); +Console.WriteLine(node.LocalName); +//You can edit the returned XmlNode. +``` + ]]> diff --git a/xml/System.Xml/IXmlLineInfo.xml b/xml/System.Xml/IXmlLineInfo.xml index 4f49381ceb1..e8db612e4c5 100644 --- a/xml/System.Xml/IXmlLineInfo.xml +++ b/xml/System.Xml/IXmlLineInfo.xml @@ -46,15 +46,14 @@ Provides an interface to enable a class to return line and position information. - @@ -147,11 +146,11 @@ Gets the current line number. The current line number or 0 if no line information is available (for example, returns ). - , a value of 1,1 indicates the start of a document. - + , a value of 1,1 indicates the start of a document. + ]]> @@ -198,11 +197,11 @@ Gets the current line position. The current line position or 0 if no line information is available (for example, returns ). - , a value of 1,1 indicates the start of a document. - + , a value of 1,1 indicates the start of a document. + ]]> diff --git a/xml/System.Xml/NameTable.xml b/xml/System.Xml/NameTable.xml index 77ce0e5d57c..fe637c1a872 100644 --- a/xml/System.Xml/NameTable.xml +++ b/xml/System.Xml/NameTable.xml @@ -54,22 +54,21 @@ Implements a single-threaded . - and , use the `NameTable` class internally to store attribute and element names. When an element or attribute name occurs multiple times in an XML document, it is stored only once in the `NameTable`. - - The names are stored as common language runtime (CLR) object types. This enables you to do object comparisons on these strings rather than a more expensive string comparison. These string objects are referred to as atomized strings. - - - -## Examples - The following example compares two element names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/NameTable/CPP/nametable.cpp" id="Snippet1"::: + and , use the `NameTable` class internally to store attribute and element names. When an element or attribute name occurs multiple times in an XML document, it is stored only once in the `NameTable`. + + The names are stored as common language runtime (CLR) object types. This enables you to do object comparisons on these strings rather than a more expensive string comparison. These string objects are referred to as atomized strings. + + + +## Examples + The following example compares two element names. + :::code language="csharp" source="~/snippets/csharp/System.Xml/NameTable/Overview/nametable.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/NameTable/VB/nametable.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/NameTable/VB/nametable.vb" id="Snippet1"::: + ]]> @@ -112,11 +111,11 @@ Initializes a new instance of the class. - @@ -131,11 +130,11 @@ Atomizes the specified string and adds it to the . - . - + . + ]]> @@ -186,11 +185,11 @@ Atomizes the specified string and adds it to the . The atomized string or the existing string if it already exists in the . - . - + . + ]]> @@ -247,23 +246,23 @@ Atomizes the specified string and adds it to the . The atomized string or the existing string if one already exists in the . If is zero, String.Empty is returned. - . - + . + ]]> - 0 > - - -or- - - >= .Length - - -or- - - >= .Length - + 0 > + + -or- + + >= .Length + + -or- + + >= .Length + The above conditions do not cause an exception to be thrown if =0. < 0. @@ -279,11 +278,11 @@ Gets the atomized string. - . - + . + ]]> @@ -335,11 +334,11 @@ Gets the atomized string with the specified value. The atomized string object or if the string has not already been atomized. - . - + . + ]]> @@ -397,23 +396,23 @@ Gets the atomized string containing the same characters as the specified range of characters in the given array. The atomized string or if the string has not already been atomized. If is zero, String.Empty is returned. - . - + . + ]]> - 0 > - - -or- - - >= .Length - - -or- - - >= .Length - + 0 > + + -or- + + >= .Length + + -or- + + >= .Length + The above conditions do not cause an exception to be thrown if =0. < 0. diff --git a/xml/System.Xml/XmlAttribute.xml b/xml/System.Xml/XmlAttribute.xml index a45ab45461e..65873b838a9 100644 --- a/xml/System.Xml/XmlAttribute.xml +++ b/xml/System.Xml/XmlAttribute.xml @@ -64,13 +64,13 @@ Represents an attribute. Valid and default values for the attribute are defined in a document type definition (DTD) or schema. - property to get the to which the attribute belongs. - - The `XmlElement` class has several methods which allow you to access attribute nodes (, , , and so on). Additionally, you can call the property, which returns an enabling you to access attributes by name or index from the collection. - + property to get the to which the attribute belongs. + + The `XmlElement` class has several methods which allow you to access attribute nodes (, , , and so on). Additionally, you can call the property, which returns an enabling you to access attributes by name or index from the collection. + ]]> Accessing Attributes in the DOM @@ -143,11 +143,11 @@ The parent XML document. Initializes a new instance of the class. - directly; instead, use methods such as . - + directly; instead, use methods such as . + ]]> @@ -200,25 +200,25 @@ Adds the specified node to the end of the list of child nodes, of this node. The added. - to import the node to the current document. The imported node can then be inserted into the current document. - - - -## Examples - For an example of the method, see the method. - + to import the node to the current document. The imported node can then be inserted into the current document. + + + +## Examples + For an example of the method, see the method. + ]]> - This node is of a type that does not allow child nodes of the type of the node. - + This node is of a type that does not allow child nodes of the type of the node. + The is an ancestor of this node. - The was created from a different document than the one that created this node. - + The was created from a different document than the one that created this node. + This node is read-only. @@ -266,28 +266,27 @@ Gets the base Uniform Resource Identifier (URI) of the node. The location from which the node was loaded or String.Empty if the node has no base URI. Attribute nodes have the same base URI as their owner element. If an attribute node does not have an owner element, returns String.Empty. - . - - This property is a Microsoft extension to the Document Object Model (DOM). + . + + This property is a Microsoft extension to the Document Object Model (DOM). + + + +## Examples + The following example displays information on the attribute node, including its base URI. - - -## Examples - The following example displays information on the attribute node, including its base URI. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlAttribute/BaseURI/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/VB/source.vb" id="Snippet1"::: - - The sample uses the file, `baseuri.xml`, as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/VB/source.vb" id="Snippet1"::: + + The sample uses the file, `baseuri.xml`, as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -342,26 +341,25 @@ Creates a duplicate of this node. The duplicate node. - returns `null`). - - Cloning an unspecified attribute returns a specified attribute ( returns `true`). - - - -## Examples - The following example uses `CloneNode` to add an attribute to two different element nodes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/CPP/source.cpp" id="Snippet1"::: + returns `null`). + + Cloning an unspecified attribute returns a specified attribute ( returns `true`). + + + +## Examples + The following example uses `CloneNode` to add an attribute to two different element nodes. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlAttribute/CloneNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/VB/source.vb" id="Snippet1"::: - - The example uses the file, `2elems.xml`, as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/VB/source.vb" id="Snippet1"::: + + The example uses the file, `2elems.xml`, as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -414,13 +412,13 @@ Sets the concatenated values of the node and all its children. The concatenated values of the node and all its children. For attribute nodes, this property has the same functionality as the property. - @@ -474,11 +472,11 @@ Sets the value of the attribute. The attribute value. - The XML specified when setting this property is not well-formed. @@ -543,29 +541,29 @@ Inserts the specified node immediately after the specified reference node. The inserted. - object, its child nodes are inserted, in the same order, after `refChild`. If the `newChild` is already in the tree, it is first removed. - - If the node being inserted was created from another document, you can use to import the node to the current document. The imported node can then be inserted into the current document. - - This method is a Microsoft extension to the Document Object Model (DOM). - - - -## Examples - For an example of the method see the method. - + object, its child nodes are inserted, in the same order, after `refChild`. If the `newChild` is already in the tree, it is first removed. + + If the node being inserted was created from another document, you can use to import the node to the current document. The imported node can then be inserted into the current document. + + This method is a Microsoft extension to the Document Object Model (DOM). + + + +## Examples + For an example of the method see the method. + ]]> - This node is of a type that does not allow child nodes of the type of the node. - + This node is of a type that does not allow child nodes of the type of the node. + The is an ancestor of this node. - The was created from a different document than the one that created this node. - - The is not a child of this node. - + The was created from a different document than the one that created this node. + + The is not a child of this node. + This node is read-only. @@ -626,27 +624,27 @@ Inserts the specified node immediately before the specified reference node. The inserted. - object, its child nodes are inserted, in the same order, before `refChild`. If the `newChild` is already in the tree, it is first removed. - - If the node being inserted was created from another document, you can use to import the node to the current document. The imported node can then be inserted into the current document. - - - -## Examples - For an example of the method, see the method. - + object, its child nodes are inserted, in the same order, before `refChild`. If the `newChild` is already in the tree, it is first removed. + + If the node being inserted was created from another document, you can use to import the node to the current document. The imported node can then be inserted into the current document. + + + +## Examples + For an example of the method, see the method. + ]]> - The current node is of a type that does not allow child nodes of the type of the node. - + The current node is of a type that does not allow child nodes of the type of the node. + The is an ancestor of this node. - The was created from a different document than the one that created this node. - - The is not a child of this node. - + The was created from a different document than the one that created this node. + + The is not a child of this node. + This node is read-only. @@ -694,20 +692,19 @@ Gets the local name of the node. The name of the attribute node with the prefix removed. In the following example <book bk:genre= 'novel'>, the of the attribute is . - . - - - -## Examples - The following example displays information on each of the nodes in the attribute collection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/CPP/source.cpp" id="Snippet1"::: + . + + + +## Examples + The following example displays information on each of the nodes in the attribute collection. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlAttribute/LocalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -756,15 +753,14 @@ Gets the qualified name of the node. The qualified name of the attribute node. - @@ -814,20 +810,19 @@ Gets the namespace URI of this node. The namespace URI of this node. If the attribute is not explicitly given a namespace, this property returns String.Empty. - @@ -923,15 +918,14 @@ Gets the to which this node belongs. An XML document to which this node belongs. - @@ -987,15 +981,14 @@ Gets the to which the attribute belongs. The that the attribute belongs to or if this attribute is not part of an . - @@ -1051,11 +1044,11 @@ Gets the parent of this node. For nodes, this property always returns . For nodes, this property always returns . - property to get the to which the attribute belongs. - + property to get the to which the attribute belongs. + ]]> @@ -1104,33 +1097,32 @@ Gets or sets the namespace prefix of this node. The namespace prefix of this node. If there is no prefix, this property returns String.Empty. - This node is read-only. - The specified prefix contains an invalid character. - - The specified prefix is malformed. - - The namespaceURI of this node is . - - The specified prefix is "xml", and the namespaceURI of this node is different from "http://www.w3.org/XML/1998/namespace". - - This node is an attribute, the specified prefix is "xmlns", and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/". - + The specified prefix contains an invalid character. + + The specified prefix is malformed. + + The namespaceURI of this node is . + + The specified prefix is "xml", and the namespaceURI of this node is different from "http://www.w3.org/XML/1998/namespace". + + This node is an attribute, the specified prefix is "xmlns", and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/". + This node is an attribute, and the qualifiedName of this node is "xmlns" [Namespaces]. @@ -1182,27 +1174,27 @@ Adds the specified node to the beginning of the list of child nodes for this node. The added. - to import the node to the current document. The imported node can then be inserted into the current document. - - This method is a Microsoft extension to the Document Object Model (DOM). - - - -## Examples - For an example of the method, see the method. - + to import the node to the current document. The imported node can then be inserted into the current document. + + This method is a Microsoft extension to the Document Object Model (DOM). + + + +## Examples + For an example of the method, see the method. + ]]> - This node is of a type that does not allow child nodes of the type of the node. - + This node is of a type that does not allow child nodes of the type of the node. + The is an ancestor of this node. - The was created from a different document than the one that created this node. - + The was created from a different document than the one that created this node. + This node is read-only. @@ -1253,11 +1245,11 @@ Removes the specified child node. The removed. - method, see the method. - + method, see the method. + ]]> The is not a child of this node. Or this node is read-only. @@ -1312,27 +1304,27 @@ Replaces the child node specified with the new child node specified. The replaced. - to import the node to the current document. - - - -## Examples - For an example of the method, see the method. - + to import the node to the current document. + + + +## Examples + For an example of the method, see the method. + ]]> - This node is of a type that does not allow child nodes of the type of the node. - + This node is of a type that does not allow child nodes of the type of the node. + The is an ancestor of this node. - The was created from a different document than the one that created this node. - - This node is read-only. - + The was created from a different document than the one that created this node. + + This node is read-only. + The is not a child of this node. @@ -1383,11 +1375,11 @@ Gets the post-schema-validation-infoset that has been assigned to this node as a result of schema validation. An containing the post-schema-validation-infoset of this node. - property is set when this node is validated. - + property is set when this node is validated. + ]]> @@ -1437,19 +1429,19 @@ if this attribute was explicitly given a value in the original instance document; otherwise, . A value of indicates that the value of the attribute came from the DTD. - @@ -1498,15 +1490,14 @@ Gets or sets the value of the node. The value returned depends on the of the node. For nodes, this property is the value of attribute. - The node is read-only and a set operation is called. @@ -1565,11 +1556,11 @@ The to which you want to save. Saves all the children of the node to the specified . - property. - + property. + ]]> @@ -1621,11 +1612,11 @@ The to which you want to save. Saves the node to the specified . - property. - + property. + ]]> diff --git a/xml/System.Xml/XmlAttributeCollection.xml b/xml/System.Xml/XmlAttributeCollection.xml index 1c921bfaf72..318a8ea8717 100644 --- a/xml/System.Xml/XmlAttributeCollection.xml +++ b/xml/System.Xml/XmlAttributeCollection.xml @@ -75,11 +75,11 @@ Represents a collection of attributes that can be accessed by name or index. - class by adding strongly typed helper methods. You can use this class to add, remove, or modify attributes in the collection. `XmlAttributeCollection` is returned by the property. - + class by adding strongly typed helper methods. You can use this class to add, remove, or modify attributes in the collection. `XmlAttributeCollection` is returned by the property. + ]]> @@ -142,22 +142,21 @@ Inserts the specified attribute as the last node in the collection. The to append to the collection. - @@ -213,20 +212,19 @@ The index in the array where copying begins. Copies all the objects from this collection into the given array. - @@ -294,22 +292,21 @@ Inserts the specified attribute immediately after the specified reference attribute. The to insert into the collection. - The was created from a document different from the one that created this collection. Or the is not a member of this collection. @@ -378,22 +375,21 @@ Inserts the specified attribute immediately before the specified reference attribute. The to insert into the collection. - The was created from a document different from the one that created this collection. Or the is not a member of this collection. @@ -459,20 +455,19 @@ Gets the attribute with the specified index. The attribute at the specified index. - . - - - -## Examples - The following example displays all the attributes in the collection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/CPP/source.cpp" id="Snippet1"::: + . + + + +## Examples + The following example displays all the attributes in the collection. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlAttributeCollection/ItemOf/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/VB/source.vb" id="Snippet1"::: + ]]> The index being passed in is out of range. @@ -537,20 +532,19 @@ Gets the attribute with the specified name. The attribute with the specified name. If the attribute does not exist, this property returns . - . - - - -## Examples - The following example removes an attribute from the document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/CPP/source.cpp" id="Snippet1"::: + . + + + +## Examples + The following example removes an attribute from the document. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlAttributeCollection/ItemOf/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -622,11 +616,11 @@ Gets the attribute with the specified local name and namespace Uniform Resource Identifier (URI). The attribute with the specified local name and namespace URI. If the attribute does not exist, this property returns . - . - + . + ]]> @@ -684,22 +678,21 @@ Inserts the specified attribute as the first node in the collection. The added to the collection. - @@ -758,20 +751,19 @@ Removes the specified attribute from the collection. The node removed or if it is not found in the collection. - @@ -825,20 +817,19 @@ Removes all attributes from the collection. - @@ -897,20 +888,19 @@ Removes the attribute corresponding to the specified index from the collection. Returns if there is no attribute at the specified index. - @@ -964,20 +954,19 @@ Adds a using its property. If the replaces an existing node with the same name, the old node is returned; otherwise, the added node is returned. - - was created from a different than the one that created this collection. - + was created from a different than the one that created this collection. + This is read-only. is an that is already an attribute of another object. To re-use attributes in other elements, you must clone the objects you want to re-use. @@ -1035,11 +1024,11 @@ The index in the array where copying begins. For a description of this member, see . - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1090,11 +1079,11 @@ For a description of this member, see . An that contains the count of the attributes. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1146,11 +1135,11 @@ if the collection is synchronized. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1201,11 +1190,11 @@ For a description of this member, see . The that is the root of the collection. - instance is cast to an interface. - + instance is cast to an interface. + ]]> diff --git a/xml/System.Xml/XmlConvert.xml b/xml/System.Xml/XmlConvert.xml index dc76605aed8..d41290f09e2 100644 --- a/xml/System.Xml/XmlConvert.xml +++ b/xml/System.Xml/XmlConvert.xml @@ -168,7 +168,6 @@ ## Examples The following example encodes and decodes names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/DecodeName/convert.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.EncodeName/VB/convert.vb" id="Snippet1"::: @@ -243,7 +242,6 @@ ## Examples The following example encodes and decodes names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/DecodeName/convert.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.EncodeName/VB/convert.vb" id="Snippet1"::: @@ -322,7 +320,6 @@ ## Examples The following example encodes and decodes names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/DecodeName/convert.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.EncodeName/VB/convert.vb" id="Snippet1"::: @@ -921,7 +918,6 @@ ## Examples The following example uses and `ToDateTime` to read strongly typed data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.ToDouble/CPP/readData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/ToDateTime/readdata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.ToDouble/VB/readdata.vb" id="Snippet1"::: @@ -1500,7 +1496,6 @@ ## Examples The following example uses `ToDouble` and to read strongly typed data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.ToDouble/CPP/readData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/ToDateTime/readdata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.ToDouble/VB/readdata.vb" id="Snippet1"::: @@ -2238,7 +2233,6 @@ ## Examples The following example, converts data types to string and then writes the information out to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/ToString/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/VB/source.vb" id="Snippet1"::: @@ -2347,7 +2341,6 @@ ## Examples The following example, converts data types to string and then writes the information out to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/ToString/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/VB/source.vb" id="Snippet1"::: @@ -2828,7 +2821,6 @@ ## Examples The following example, converts data types to string and then writes the information out to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/ToString/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/VB/source.vb" id="Snippet1"::: @@ -3248,7 +3240,6 @@ catch(Exception e) ## Examples The following example uses the `VerifyName` method to write an element name. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.VerifyName/CPP/verifyname.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/VerifyName/verifyname.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.VerifyName/VB/verifyname.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlDataDocument.xml b/xml/System.Xml/XmlDataDocument.xml index 3cfc90d5e26..109f2f3d321 100644 --- a/xml/System.Xml/XmlDataDocument.xml +++ b/xml/System.Xml/XmlDataDocument.xml @@ -52,17 +52,17 @@ Allows structured data to be stored, retrieved, and manipulated through a relational . - . It enables you to load either relational data or XML data and manipulate that data using the World Wide Web Consortium (W3C) Document Object Model (DOM). The DOM presents data as a hierarchy of node objects. Because `XmlDataDocument` implements the interface, it can also be used as the source document for the class. - - `XmlDataDocument` has a close affiliation with the `DataSet` class, which provides a relational view of the loaded XML data. Any changes made to the `XmlDataDocument` are reflected in the `DataSet` and vice versa. - - To load a `DataSet` with XML data, use to build a relational mapping. The XML data can then be loaded using or . - - To load relational data, specify the `DataSet` containing the relational data as the parameter in the constructor. - + . It enables you to load either relational data or XML data and manipulate that data using the World Wide Web Consortium (W3C) Document Object Model (DOM). The DOM presents data as a hierarchy of node objects. Because `XmlDataDocument` implements the interface, it can also be used as the source document for the class. + + `XmlDataDocument` has a close affiliation with the `DataSet` class, which provides a relational view of the loaded XML data. Any changes made to the `XmlDataDocument` are reflected in the `DataSet` and vice versa. + + To load a `DataSet` with XML data, use to build a relational mapping. The XML data can then be loaded using or . + + To load relational data, specify the `DataSet` containing the relational data as the parameter in the constructor. + ]]> @@ -112,11 +112,11 @@ Initializes a new instance of the class. - is created and associated with the `XmlDataDocument`. - + is created and associated with the `XmlDataDocument`. + ]]> @@ -160,22 +160,21 @@ The to load into . Initializes a new instance of the class with the specified . - @@ -220,28 +219,27 @@ Creates a duplicate of the current node. The cloned node. - schema. - - If `deep` is set to `false`, the cloned `DataSet` has no data; that is, no rows. - - If `deep` is set to `true`, the cloned `DataSet` is set with the schema and then populated with the data. - - See in the `XmlNode` class to see a table describing how this method behaves with each of the different node types. - - - -## Examples - The following example loads a `DataSet` into an `XmlDataDocument` and then creates a shallow clone of the `XmlDataDocument`. - - The example uses the SQL Server 2000 Northwind database. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/CPP/source.cpp" id="Snippet1"::: + schema. + + If `deep` is set to `false`, the cloned `DataSet` has no data; that is, no rows. + + If `deep` is set to `true`, the cloned `DataSet` is set with the schema and then populated with the data. + + See in the `XmlNode` class to see a table describing how this method behaves with each of the different node types. + + + +## Examples + The following example loads a `DataSet` into an `XmlDataDocument` and then creates a shallow clone of the `XmlDataDocument`. + + The example uses the SQL Server 2000 Northwind database. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDataDocument/CloneNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -302,22 +300,22 @@ Creates an element with the specified , , and . A new . - @@ -359,11 +357,11 @@ class MyXmlDataDocument : XmlDataDocument { Creates an with the specified name. An with the specified name. - nodes cannot be created for objects. Calling this method throws an exception. - + nodes cannot be created for objects. Calling this method throws an exception. + ]]> Calling this method. @@ -413,16 +411,16 @@ class MyXmlDataDocument : XmlDataDocument { Creates a new object for navigating this document. The is positioned on the node specified in the parameter. An used to navigate the document. - method. - - - -## Examples - To see an XSLT transformation using `XmlDataDocument` and an `XPathNavigator`, see the method. - + method. + + + +## Examples + To see an XSLT transformation using `XmlDataDocument` and an `XPathNavigator`, see the method. + ]]> @@ -461,30 +459,29 @@ class MyXmlDataDocument : XmlDataDocument { Gets a that provides a relational representation of the data in the . A that can be used to access the data in the using a relational model. - @@ -535,11 +532,11 @@ class MyXmlDataDocument : XmlDataDocument { Gets the with the specified ID. This method is not supported by the class. Calling this method throws an exception. An with the specified ID. - class. - + class. + ]]> Calling this method. @@ -582,17 +579,16 @@ class MyXmlDataDocument : XmlDataDocument { Retrieves the associated with the specified . The containing a representation of the specified . - @@ -635,13 +631,13 @@ class MyXmlDataDocument : XmlDataDocument { Returns an containing a list of all descendant elements that match the specified . An containing a list of all matching nodes. - [!NOTE] -> It is recommended that you use the or method instead of the method. - +> It is recommended that you use the or method instead of the method. + ]]> @@ -684,25 +680,24 @@ class MyXmlDataDocument : XmlDataDocument { Retrieves the associated with the specified . The containing a representation of the ; if there is no associated with the . - @@ -716,15 +711,15 @@ class MyXmlDataDocument : XmlDataDocument { Loads the using the specified data source and synchronizes the with the loaded data. - [!NOTE] -> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. - - `XmlDataDocument` does not support creating entity references. If the data includes entity references, the `Load` method resolves and expands any entity references. However, if you are using the `Load` overload that takes a as an argument, you must specify an `XmlReader` that can resolve entities. - +> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. + + `XmlDataDocument` does not support creating entity references. If the data includes entity references, the `Load` method resolves and expands any entity references. However, if you are using the `Load` overload that takes a as an argument, you must specify an `XmlReader` that can resolve entities. + ]]> @@ -765,14 +760,14 @@ class MyXmlDataDocument : XmlDataDocument { The stream containing the XML document to load. Loads the from the specified stream. - [!NOTE] -> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. - +> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. + ]]> @@ -813,14 +808,14 @@ class MyXmlDataDocument : XmlDataDocument { The used to feed the XML data into the document. Loads the from the specified . - [!NOTE] -> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. - +> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. + ]]> @@ -861,14 +856,14 @@ class MyXmlDataDocument : XmlDataDocument { The URL of the file containing the XML document to load. Loads the using the specified URL. - [!NOTE] -> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. - +> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. + ]]> @@ -909,53 +904,52 @@ class MyXmlDataDocument : XmlDataDocument { The containing the XML document to load. Loads the from the specified . - with the property set to EntityHandling.ExpandEntities (this is the default behavior) and pass the `XmlValidatingReader` to the `Load` method. If you do not use an `XmlValidatingReader`, the `Load` method throws an exception. - - The `Load` method always preserves significant white space. The property determines whether or not white space is preserved. The default is `false`, white space is not preserved. - - If the reader is in the initial state (that is, ReadState=ReadState.Initial), `Load` consumes the entire contents of the reader and builds the DOM from what it finds. - - If the reader is already positioned on some node at depth "n", then this method loads that node and all subsequent siblings up to the end tag that closes depth "n". This has the following results. - - If the current node and its following siblings look similar to the following: - -```xml -onetwo -``` - - `Load` throws an exception, because a document cannot have two root-level elements. If the current node and its following siblings look similar to the following: - -```xml - -``` - - `Load` will succeed; however, you will have an incomplete DOM tree, because there is no root-level element. You have to add a root-level element before you save the document; otherwise, the method throws an exception. - - If the reader is positioned on a leaf node that is invalid for the root level of a document (for example, a white space or attribute node), the reader continues to read until it is positioned on a node that can be used for the root. The document begins loading at this point. - - - -## Examples - The following example modifies the price of a book using the `DataSet` methods. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlDataDocument.Load/CPP/loadrdr.cpp" id="Snippet1"::: + with the property set to EntityHandling.ExpandEntities (this is the default behavior) and pass the `XmlValidatingReader` to the `Load` method. If you do not use an `XmlValidatingReader`, the `Load` method throws an exception. + + The `Load` method always preserves significant white space. The property determines whether or not white space is preserved. The default is `false`, white space is not preserved. + + If the reader is in the initial state (that is, ReadState=ReadState.Initial), `Load` consumes the entire contents of the reader and builds the DOM from what it finds. + + If the reader is already positioned on some node at depth "n", then this method loads that node and all subsequent siblings up to the end tag that closes depth "n". This has the following results. + + If the current node and its following siblings look similar to the following: + +```xml +onetwo +``` + + `Load` throws an exception, because a document cannot have two root-level elements. If the current node and its following siblings look similar to the following: + +```xml + +``` + + `Load` will succeed; however, you will have an incomplete DOM tree, because there is no root-level element. You have to add a root-level element before you save the document; otherwise, the method throws an exception. + + If the reader is positioned on a leaf node that is invalid for the root level of a document (for example, a white space or attribute node), the reader continues to read until it is positioned on a node that can be used for the root. The document begins loading at this point. + + + +## Examples + The following example modifies the price of a book using the `DataSet` methods. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDataDocument/Load/loadrdr.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.Load/VB/loadrdr.vb" id="Snippet1"::: - - The example uses the following two input files. - - `2books.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.Load/XML/2books.xml" id="Snippet2"::: - - `store.xsd` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.Load/XML/test.xsd" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.Load/VB/loadrdr.vb" id="Snippet1"::: + + The example uses the following two input files. + + `2books.xml` + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.Load/XML/2books.xml" id="Snippet2"::: + + `store.xsd` + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.Load/XML/test.xsd" id="Snippet3"::: + ]]> The XML being loaded contains entity references, and the reader cannot resolve entities. diff --git a/xml/System.Xml/XmlDeclaration.xml b/xml/System.Xml/XmlDeclaration.xml index 443055e32b8..109c744b505 100644 --- a/xml/System.Xml/XmlDeclaration.xml +++ b/xml/System.Xml/XmlDeclaration.xml @@ -64,11 +64,11 @@ Represents the XML declaration node <?xml version='1.0'...?>. - @@ -140,11 +140,11 @@ The parent XML document. Initializes a new instance of the class. - directly; instead, use methods such as . - + directly; instead, use methods such as . + ]]> @@ -198,13 +198,13 @@ Creates a duplicate of this node. The cloned node. - . - - The cloned node has no parent ( returns `null`). - + . + + The cloned node has no parent ( returns `null`). + ]]> @@ -257,48 +257,47 @@ Gets or sets the encoding level of the XML document. - The valid character encoding name. The most commonly supported character encoding names for XML are the following: - - Category - - Encoding Names - - Unicode - - UTF-8, UTF-16 - - ISO 10646 - - ISO-10646-UCS-2, ISO-10646-UCS-4 - - ISO 8859 - - ISO-8859-n (where "n" is a digit from 1 to 9) - - JIS X-0208-1997 - - ISO-2022-JP, Shift_JIS, EUC-JP - - + The valid character encoding name. The most commonly supported character encoding names for XML are the following: + + Category + + Encoding Names + + Unicode + + UTF-8, UTF-16 + + ISO 10646 + + ISO-10646-UCS-2, ISO-10646-UCS-4 + + ISO 8859 + + ISO-8859-n (where "n" is a digit from 1 to 9) + + JIS X-0208-1997 + + ISO-2022-JP, Shift_JIS, EUC-JP + + + + This value is optional. If a value is not set, this property returns String.Empty. - This value is optional. If a value is not set, this property returns String.Empty. - If an encoding attribute is not included, UTF-8 encoding is assumed when the document is written or saved out. - @@ -538,15 +537,14 @@ Gets or sets the value of the standalone attribute. Valid values are if all entity declarations required by the XML document are contained within the document or if an external document type definition (DTD) is required. If a standalone attribute is not present in the XML declaration, this property returns String.Empty. - @@ -756,11 +754,11 @@ The to which you want to save. Saves the node to the specified . - and properties. If either of the properties is not set, the corresponding attribute is not written. The version attribute is always written out with a value of 1.0. - + and properties. If either of the properties is not set, the corresponding attribute is not written. The version attribute is always written out with a value of 1.0. + ]]> diff --git a/xml/System.Xml/XmlDocumentFragment.xml b/xml/System.Xml/XmlDocumentFragment.xml index 0126077e919..7cf3bdc5935 100644 --- a/xml/System.Xml/XmlDocumentFragment.xml +++ b/xml/System.Xml/XmlDocumentFragment.xml @@ -112,11 +112,11 @@ The XML document that is the source of the fragment. Initializes a new instance of the class. - directly; instead, use methods such as . - + directly; instead, use methods such as . + ]]> @@ -170,22 +170,21 @@ Creates a duplicate of this node. The cloned node. - . - - The cloned node has no parent ( returns `null`). - - - -## Examples - The following example shows the difference between a deep and shallow clone. + . + + The cloned node has no parent ( returns `null`). + + + +## Examples + The following example shows the difference between a deep and shallow clone. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocumentFragment/CloneNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -234,22 +233,21 @@ Gets or sets the markup representing the children of this node. The markup of the children of this node. - The XML specified when setting this property is not well-formed. @@ -438,20 +436,19 @@ Gets the to which this node belongs. The to which this node belongs. - @@ -505,8 +502,8 @@ Gets the parent of this node (for nodes that can have parents). - The parent of this node. - + The parent of this node. + For nodes, this property is always . To be added. @@ -558,11 +555,11 @@ The to which you want to save. Saves all the children of the node to the specified . - @@ -614,11 +611,11 @@ The to which you want to save. Saves the node to the specified . - diff --git a/xml/System.Xml/XmlDocumentType.xml b/xml/System.Xml/XmlDocumentType.xml index 224a7c45666..a8df4d71c09 100644 --- a/xml/System.Xml/XmlDocumentType.xml +++ b/xml/System.Xml/XmlDocumentType.xml @@ -50,11 +50,11 @@ Represents the document type declaration. - class can be used to return information about a document type declaration. Use the method to create an object. - + class can be used to return information about a document type declaration. Use the method to create an object. + ]]> @@ -123,11 +123,11 @@ The parent document. Initializes a new instance of the class. - directly; instead, use members such as to obtain one. - + directly; instead, use members such as to obtain one. + ]]> @@ -176,13 +176,13 @@ Creates a duplicate of this node. The cloned node. - returns `null`). - - To see how this method behaves with other node types, see . - + returns `null`). + + To see how this method behaves with other node types, see . + ]]> @@ -226,24 +226,23 @@ Gets the collection of nodes declared in the document type declaration. An containing the nodes. The returned is read-only. - @@ -298,15 +297,14 @@ Gets the value of the document type definition (DTD) internal subset on the DOCTYPE declaration. The DTD internal subset on the DOCTYPE. If there is no DTD internal subset, String.Empty is returned. - @@ -349,28 +347,27 @@ Gets a value indicating whether the node is read-only. - if the node is read-only; otherwise, . - + if the node is read-only; otherwise, . + Because DocumentType nodes are read-only, this property always returns . - @@ -467,15 +464,14 @@ Gets the qualified name of the node. For DocumentType nodes, this property returns the name of the document type. - @@ -561,24 +557,23 @@ Gets the collection of nodes present in the document type declaration. An containing the nodes. The returned is read-only. - diff --git a/xml/System.Xml/XmlElement.xml b/xml/System.Xml/XmlElement.xml index 8565a947cb5..292655816e4 100644 --- a/xml/System.Xml/XmlElement.xml +++ b/xml/System.Xml/XmlElement.xml @@ -64,11 +64,11 @@ Represents an element. - , , , , and so on). You can also use the property which returns an enabling you to access attributes by name or index from the collection. - + , , , , and so on). You can also use the property which returns an enabling you to access attributes by name or index from the collection. + ]]> @@ -144,11 +144,11 @@ The parent XML document. Initializes a new instance of the class. - directly; instead, use methods such as . - + directly; instead, use methods such as . + ]]> @@ -198,15 +198,14 @@ containing the list of attributes for this node. - @@ -260,20 +259,19 @@ Creates a duplicate of this node. The cloned node. - returns `null`). - - - -## Examples - The following example creates a new element, clones it, and then adds both elements into an XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/CPP/source.cpp" id="Snippet1"::: + returns `null`). + + + +## Examples + The following example creates a new element, clones it, and then adds both elements into an XML document. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/CloneNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -335,15 +333,14 @@ Returns the value for the attribute with the specified name. The value of the specified attribute. An empty string is returned if a matching attribute is not found or if the attribute does not have a specified or default value. - @@ -466,15 +463,14 @@ Returns the with the specified name. The specified or if a matching attribute was not found. - @@ -596,27 +592,26 @@ Returns an containing a list of all descendant elements that match the specified . An containing a list of all matching nodes. The list is empty if there are no matching nodes. - tree. - + tree. + > [!NOTE] -> It is recommended that you use the or method instead of the method. - - - -## Examples - The following example gets and displays all the book titles. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp" id="Snippet1"::: +> It is recommended that you use the or method instead of the method. + + + +## Examples + The following example gets and displays all the book titles. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/GetElementsByTagName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: - - The example uses the file, `2books.xml`, as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: + + The example uses the file, `2books.xml`, as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -671,14 +666,14 @@ Returns an containing a list of all descendant elements that match the specified and . An containing a list of all matching nodes. The list is empty if there are no matching nodes. - [!NOTE] -> It is recommended that you use the or method instead of the method. - +> It is recommended that you use the or method instead of the method. + ]]> @@ -741,15 +736,14 @@ if the current node has the specified attribute; otherwise, . - @@ -860,20 +854,19 @@ if the current node has attributes; otherwise, . - @@ -922,22 +915,21 @@ Gets or sets the concatenated values of the node and all its children. The concatenated values of the node and all its children. - properties. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/CPP/source.cpp" id="Snippet1"::: + +This property is a Microsoft extension to the Document Object Model (DOM). + +## Examples + The following example compares the `InnerText` and properties. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/InnerText/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -986,22 +978,21 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets or sets the markup representing just the children of this node. The markup of the children of this node. - and `InnerXml` properties. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/CPP/source.cpp" id="Snippet1"::: + and `InnerXml` properties. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/InnerText/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/VB/source.vb" id="Snippet1"::: + ]]> The XML specified when setting this property is not well-formed. @@ -1050,26 +1041,25 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets or sets the tag format of the element. - if the element is to be serialized in the short tag format "<item/>"; for the long format "<item></item>". - - When setting this property, if set to , the children of the element are removed and the element is serialized in the short tag format. If set to , the value of the property is changed (regardless of whether or not the element has content); if the element is empty, it is serialized in the long format. - + if the element is to be serialized in the short tag format "<item/>"; for the long format "<item></item>". + + When setting this property, if set to , the children of the element are removed and the element is serialized in the short tag format. If set to , the value of the property is changed (regardless of whether or not the element has content); if the element is empty, it is serialized in the long format. + This property is a Microsoft extension to the Document Object Model (DOM). - @@ -1118,20 +1108,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets the local name of the current node. The name of the current node with the prefix removed. For example, is book for the element <bk:book>. - . - - - -## Examples - The following example displays information on the ISBN element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp" id="Snippet1"::: + . + + + +## Examples + The following example displays information on the ISBN element. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/LocalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1180,15 +1169,14 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets the qualified name of the node. The qualified name of the node. For nodes, this is the tag name of the element. - @@ -1238,20 +1226,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets the namespace URI of this node. The namespace URI of this node. If there is no namespace URI, this property returns String.Empty. - - - - -## Examples - The following example displays information on the ISBN element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp" id="Snippet1"::: + + + + +## Examples + The following example displays information on the ISBN element. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/LocalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1400,20 +1387,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets the to which this node belongs. The to which this element belongs. - @@ -1518,29 +1504,28 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets or sets the namespace prefix of this node. The namespace prefix of this node. If there is no prefix, this property returns String.Empty. - property, which holds the qualified name for an `XmlElement`. However, changing the prefix does not change the namespace URI of the element. - - - -## Examples - The following example displays information on the ISBN element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp" id="Snippet1"::: + property, which holds the qualified name for an `XmlElement`. However, changing the prefix does not change the namespace URI of the element. + + + +## Examples + The following example displays information on the ISBN element. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/LocalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: + ]]> This node is read-only. - The specified prefix contains an invalid character. - - The specified prefix is malformed. - - The namespaceURI of this node is . - + The specified prefix contains an invalid character. + + The specified prefix is malformed. + + The namespaceURI of this node is . + The specified prefix is "xml" and the namespaceURI of this node is different from http://www.w3.org/XML/1998/namespace. @@ -1588,15 +1573,14 @@ This property is a Microsoft extension to the Document Object Model (DOM). Removes all specified attributes and children of the current node. Default attributes are not removed. - @@ -1645,20 +1629,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Removes all specified attributes from the element. Default attributes are not removed. - @@ -1719,20 +1702,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). The name of the attribute to remove. This is a qualified name. It is matched against the property of the matching node. Removes an attribute by name. - The node is read-only. @@ -1795,20 +1777,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). The namespace URI of the attribute to remove. Removes an attribute with the specified local name and namespace URI. (If the removed attribute has a default value, it is immediately replaced). - The node is read-only. @@ -1863,20 +1844,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Removes the attribute node with the specified index from the element. (If the removed attribute has a default value, it is immediately replaced). The attribute node removed or if there is no node at the given index. - @@ -2000,15 +1980,14 @@ This property is a Microsoft extension to the Document Object Model (DOM). Removes the specified by the local name and namespace URI. (If the removed attribute has a default value, it is immediately replaced). The removed or if the does not have a matching attribute node. - This node is read-only. @@ -2061,11 +2040,11 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets the post schema validation infoset that has been assigned to this node as a result of schema validation. An object containing the post schema validation infoset of this node. - property is set when this node is validated. - + property is set when this node is validated. + ]]> @@ -2136,11 +2115,11 @@ This property is a Microsoft extension to the Document Object Model (DOM). The value to set for the attribute. Sets the value of the attribute with the specified name. - node plus any and nodes, build the appropriate subtree and use to assign it as the value of an attribute. - + node plus any and nodes, build the appropriate subtree and use to assign it as the value of an attribute. + ]]> The specified name contains an invalid character. @@ -2267,11 +2246,11 @@ This property is a Microsoft extension to the Document Object Model (DOM). Adds the specified . If the attribute replaces an existing attribute with the same name, the old is returned; otherwise, is returned. - The was created from a different document than the one that created this node. Or this node is read-only. @@ -2336,20 +2315,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Adds the specified . The to add. - to assign a text value to the attribute or use (or a similar method) to add children to the attribute. - - - -## Examples - The following example adds an attribute to an element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/CPP/source.cpp" id="Snippet1"::: + to assign a text value to the attribute or use (or a similar method) to add children to the attribute. + + + +## Examples + The following example adds an attribute to an element. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/SetAttributeNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2401,20 +2379,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). The to which you want to save. Saves all the children of the node to the specified . - @@ -2467,20 +2444,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). The to which you want to save. Saves the current node to the specified . - diff --git a/xml/System.Xml/XmlEntity.xml b/xml/System.Xml/XmlEntity.xml index 8822b038235..7a20bd3557a 100644 --- a/xml/System.Xml/XmlEntity.xml +++ b/xml/System.Xml/XmlEntity.xml @@ -99,68 +99,68 @@ Gets the base Uniform Resource Identifier (URI) of the current node. The location from which the node was loaded. - -]> -&xyz; -``` - - where the external entity `a/b.xml` contains the XML text `123`. - - If the document is loaded from `http://server/mydata.xml`, `BaseURI` returns the following: - -|NodeType|Name|BaseURI| -|--------------|----------|-------------| -|Attribute|num|`http://server/mydata.xml`| -|Document|#document|`http://server/mydata.xml`| -|DocumentType|item|`http://server/mydata.xml`| -|Entity|xyz|`http://server/mydata.xml`| -|Element|item|`http://server/mydata.xml`| -|EntityReference|xyz|`http://server/mydata.xml`| -|Element|test|`http://server/a/b.xml`| -|Text|#text|`http://server/a/b.xml`| - - `BaseURI` looks for entity reference boundaries, so if entities are expanded, this information is not preserved and this property returns the location of the `XmlDocument` object in all cases. - - As a second example, given the following XML document: - -```xml - -&xyz; -``` - - where the document type definition (DTD) file contains the following: - -``` -My Data"> - - -``` - - If the XML document is loaded from http://localhost/mydata.xml, `BaseURI` returns the following for each of the nodes: - -|NodeType|Name|BaseURI| -|--------------|----------|-------------| -|Document|#document|http://localhost/mydata.xml| -|DocumentType|Mydata|http://localhost/doctype.dtd| -|Element|baa|http://localhost/mydata.xml| -|Entity|xyz|http://localhost/doctype.dtd| -|EntityReference|xyz|http://localhost/mydata.xml| -|Attribute|woof|http://localhost/mydata.xml| - + +]> +&xyz; +``` + + where the external entity `a/b.xml` contains the XML text `123`. + + If the document is loaded from `http://server/mydata.xml`, `BaseURI` returns the following: + +|NodeType|Name|BaseURI| +|--------------|----------|-------------| +|Attribute|num|`http://server/mydata.xml`| +|Document|#document|`http://server/mydata.xml`| +|DocumentType|item|`http://server/mydata.xml`| +|Entity|xyz|`http://server/mydata.xml`| +|Element|item|`http://server/mydata.xml`| +|EntityReference|xyz|`http://server/mydata.xml`| +|Element|test|`http://server/a/b.xml`| +|Text|#text|`http://server/a/b.xml`| + + `BaseURI` looks for entity reference boundaries, so if entities are expanded, this information is not preserved and this property returns the location of the `XmlDocument` object in all cases. + + As a second example, given the following XML document: + +```xml + +&xyz; +``` + + where the document type definition (DTD) file contains the following: + +``` +My Data"> + + +``` + + If the XML document is loaded from http://localhost/mydata.xml, `BaseURI` returns the following for each of the nodes: + +|NodeType|Name|BaseURI| +|--------------|----------|-------------| +|Document|#document|http://localhost/mydata.xml| +|DocumentType|Mydata|http://localhost/doctype.dtd| +|Element|baa|http://localhost/mydata.xml| +|Entity|xyz|http://localhost/doctype.dtd| +|EntityReference|xyz|http://localhost/mydata.xml| +|Attribute|woof|http://localhost/mydata.xml| + > [!NOTE] -> The base URI of a default attribute is the same as the base URI of the element to which they belong. - - This property is a Microsoft extension to the Document Object Model (DOM). - +> The base URI of a default attribute is the same as the base URI of the element to which they belong. + + This property is a Microsoft extension to the Document Object Model (DOM). + ]]> @@ -251,13 +251,13 @@ Gets the concatenated values of the entity node and all its children. The concatenated values of the node and all its children. - Attempting to set the property. @@ -308,13 +308,13 @@ Gets the markup representing the children of this node. For nodes, String.Empty is returned. - Attempting to set the property. @@ -358,15 +358,15 @@ Gets a value indicating whether the node is read-only. - if the node is read-only; otherwise, . - + if the node is read-only; otherwise, . + Because nodes are read-only, this property always returns . - @@ -463,19 +463,18 @@ Gets the name of the node. The name of the entity. - @@ -520,19 +519,18 @@ Gets the type of the node. The node type. For nodes, the value is XmlNodeType.Entity. - @@ -588,19 +586,18 @@ Gets the name of the optional NDATA attribute on the entity declaration. The name of the NDATA attribute. If there is no NDATA, is returned. - @@ -651,11 +648,11 @@ Gets the markup representing this node and all its children. For nodes, String.Empty is returned. - @@ -710,19 +707,18 @@ Gets the value of the public identifier on the entity declaration. The public identifier on the entity. If there is no public identifier, is returned. - @@ -778,19 +774,18 @@ Gets the value of the system identifier on the entity declaration. The system identifier on the entity. If there is no system identifier, is returned. - @@ -838,11 +833,11 @@ The to which you want to save. Saves all the children of the node to the specified . For nodes, this method has no effect. - @@ -889,11 +884,11 @@ The to which you want to save. Saves the node to the specified . For nodes, this method has no effect. - diff --git a/xml/System.Xml/XmlEntityReference.xml b/xml/System.Xml/XmlEntityReference.xml index 1f18f861a10..56141994186 100644 --- a/xml/System.Xml/XmlEntityReference.xml +++ b/xml/System.Xml/XmlEntityReference.xml @@ -95,11 +95,11 @@ The parent XML document. Initializes a new instance of the class. - directly; instead, use methods such as . - + directly; instead, use methods such as . + ]]> Creating New Entity References @@ -144,32 +144,31 @@ Gets the base Uniform Resource Identifier (URI) of the current node. The location from which the node was loaded. - is returned. - - `BaseURI` walks the node tree looking for entity reference boundaries, so if entities are expanded, this information is not preserved and this property returns the location of the XmlDocument in all cases. - - For additional information on `BaseURI` and how it behaves with other node types, see . - - This property is a Microsoft extension to the Document Object Model (DOM). - - - -## Examples - The following example displays information on entity reference node, including its base URI. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/CPP/source.cpp" id="Snippet1"::: + is returned. + + `BaseURI` walks the node tree looking for entity reference boundaries, so if entities are expanded, this information is not preserved and this property returns the location of the XmlDocument in all cases. + + For additional information on `BaseURI` and how it behaves with other node types, see . + + This property is a Microsoft extension to the Document Object Model (DOM). + + + +## Examples + The following example displays information on entity reference node, including its base URI. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlEntityReference/BaseURI/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/VB/source.vb" id="Snippet1"::: - - The sample uses the file, `uri.xml`, as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/XML/source.xml" id="Snippet2"::: - - The `style.xml` file contains the XML string ``. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/VB/source.vb" id="Snippet1"::: + + The sample uses the file, `uri.xml`, as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/XML/source.xml" id="Snippet2"::: + + The `style.xml` file contains the XML string ``. + ]]> @@ -218,11 +217,11 @@ Creates a duplicate of this node. The cloned node. - returns `null`). - + returns `null`). + ]]> @@ -265,26 +264,25 @@ Gets a value indicating whether the node is read-only. - if the node is read-only; otherwise . - + if the node is read-only; otherwise . + Because nodes are read-only, this property always returns . - @@ -381,15 +379,14 @@ Gets the name of the node. The name of the entity referenced. - @@ -528,11 +525,11 @@ The to which you want to save. Saves all the children of the node to the specified . - @@ -579,11 +576,11 @@ The to which you want to save. Saves the node to the specified . - diff --git a/xml/System.Xml/XmlImplementation.xml b/xml/System.Xml/XmlImplementation.xml index 34ffacc853a..dd791d10ef3 100644 --- a/xml/System.Xml/XmlImplementation.xml +++ b/xml/System.Xml/XmlImplementation.xml @@ -64,13 +64,13 @@ Defines the context for a set of objects. - . This enables users to compare attribute and element names between the objects more efficiently. - - Although the `XmlDocument` objects share the same implementation, to move nodes from one document to another, you must use the method. - + . This enables users to compare attribute and element names between the objects more efficiently. + + Although the `XmlDocument` objects share the same implementation, to move nodes from one document to another, you must use the method. + ]]> @@ -222,22 +222,21 @@ Creates a new . The new object. - method. + + + +## Examples + The following example creates two `XmlDocument` objects from the same implementation. - Although the `XmlDocument` objects share the same implementation, to move nodes from one document to another, you must use the method. - - - -## Examples - The following example creates two `XmlDocument` objects from the same implementation. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlImplementation/CreateDocument/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -292,22 +291,22 @@ This is the version number of the package name to test. If the version is not specified (), supporting any version of the feature causes the method to return . Tests if the Document Object Model (DOM) implementation implements a specific feature. - if the feature is implemented in the specified version; otherwise, . - - The following table shows the combinations that cause to return . - - strFeature - - strVersion - - XML - - 1.0 - - XML - - 2.0 - + if the feature is implemented in the specified version; otherwise, . + + The following table shows the combinations that cause to return . + + strFeature + + strVersion + + XML + + 1.0 + + XML + + 2.0 + To be added. diff --git a/xml/System.Xml/XmlLinkedNode.xml b/xml/System.Xml/XmlLinkedNode.xml index e627847786d..ead542e7c1e 100644 --- a/xml/System.Xml/XmlLinkedNode.xml +++ b/xml/System.Xml/XmlLinkedNode.xml @@ -111,15 +111,14 @@ Gets the node immediately following this node. The immediately following this node or if one does not exist. - @@ -170,15 +169,14 @@ Gets the node immediately preceding this node. The preceding or if one does not exist. - diff --git a/xml/System.Xml/XmlNamedNodeMap.xml b/xml/System.Xml/XmlNamedNodeMap.xml index bbb13220a3d..ec6aed7bc4b 100644 --- a/xml/System.Xml/XmlNamedNodeMap.xml +++ b/xml/System.Xml/XmlNamedNodeMap.xml @@ -68,17 +68,17 @@ Represents a collection of nodes that can be accessed by name or index. - - Returns , a class which inherits from `XmlNamedNodeMap`. - -- - Returns an `XmlNamedNodeMap` containing objects. The `XmlNamedNodeMap` is read-only. - -- - Returns an `XmlNamedNodeMap` containing objects. The `XmlNamedNodeMap` is read-only. - + - Returns , a class which inherits from `XmlNamedNodeMap`. + +- - Returns an `XmlNamedNodeMap` containing objects. The `XmlNamedNodeMap` is read-only. + +- - Returns an `XmlNamedNodeMap` containing objects. The `XmlNamedNodeMap` is read-only. + ]]> @@ -138,15 +138,14 @@ Gets the number of nodes in the . The number of nodes. - class (which inherits from `XmlNamedNodeMap`) to display all the attributes of a book. + class (which inherits from `XmlNamedNodeMap`) to display all the attributes of a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamedNodeMap/Count/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -199,15 +198,14 @@ Provides support for the "foreach" style iteration over the collection of nodes in the . An enumerator object. - @@ -270,15 +268,14 @@ Retrieves an specified by name. An with the specified name or if a matching node is not found. - class (which inherits from `XmlNamedNodeMap`) to modify an attribute. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/CPP/source.cpp" id="Snippet1"::: + class (which inherits from `XmlNamedNodeMap`) to modify an attribute. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamedNodeMap/GetNamedItem/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -392,15 +389,14 @@ Retrieves the node at the specified index in the . The at the specified index. If is less than 0 or greater than or equal to the property, is returned. - class (which inherits from `XmlNamedNodeMap`) to display all the attributes of a book. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/CPP/source.cpp" id="Snippet1"::: + class (which inherits from `XmlNamedNodeMap`) to display all the attributes of a book. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamedNodeMap/Count/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -463,15 +459,14 @@ Removes the node from the . The removed from this or if a matching node was not found. - class (which inherits from `XmlNamedNodeMap`) to remove an attribute. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/CPP/source.cpp" id="Snippet1"::: + class (which inherits from `XmlNamedNodeMap`) to remove an attribute. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamedNodeMap/RemoveNamedItem/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -585,15 +580,14 @@ Adds an using its property. If the replaces an existing node with the same name, the old node is returned; otherwise, is returned. - class (which inherits from `XmlNamedNodeMap`) to add an attribute to the collection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/CPP/source.cpp" id="Snippet1"::: + class (which inherits from `XmlNamedNodeMap`) to add an attribute to the collection. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamedNodeMap/SetNamedItem/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/VB/source.vb" id="Snippet1"::: + ]]> The was created from a different than the one that created the ; or the is read-only. diff --git a/xml/System.Xml/XmlNamespaceManager.xml b/xml/System.Xml/XmlNamespaceManager.xml index 6bc13aef348..d1d5befd41c 100644 --- a/xml/System.Xml/XmlNamespaceManager.xml +++ b/xml/System.Xml/XmlNamespaceManager.xml @@ -212,7 +212,6 @@ while (reader.Read()) ## Examples The following example creates an using the name table of the reader. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.XmlNamespaceManager Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.XmlNamespaceManager Example/VB/source.vb" id="Snippet1"::: @@ -366,7 +365,6 @@ while (reader.Read()) ## Examples The following example displays the default namespace, if one exists. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/DefaultNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/VB/source.vb" id="Snippet1"::: @@ -570,7 +568,6 @@ Loop ## Examples The following example displays the default namespace, if one exists. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/DefaultNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/VB/source.vb" id="Snippet1"::: @@ -637,7 +634,6 @@ Loop ## Examples The following example adds prefix/namespace pairs to the , and then displays all the pairs in the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/LookupNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/VB/source.vb" id="Snippet1"::: @@ -879,7 +875,6 @@ writer.WriteEndElement() ## Examples The following example adds prefix/namespace pairs to the and then displays all the pairs in the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/LookupNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/VB/source.vb" id="Snippet1"::: @@ -942,7 +937,6 @@ writer.WriteEndElement() ## Examples The following example adds prefix/namespace pairs to the and then displays all the pairs in the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/LookupNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlNode.xml b/xml/System.Xml/XmlNode.xml index 3a5dd281656..3d19d1e592a 100644 --- a/xml/System.Xml/XmlNode.xml +++ b/xml/System.Xml/XmlNode.xml @@ -159,7 +159,6 @@ ## Examples The following example adds a new node to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.AppendChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/AppendChild/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.AppendChild Example/VB/source.vb" id="Snippet1"::: @@ -246,7 +245,6 @@ Display the modified XML... ## Examples The following example adds a new attribute to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/Attributes/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/VB/source.vb" id="Snippet1"::: @@ -420,7 +418,6 @@ Where the DTD file contains the following: ## Examples The following example displays all the child nodes of the root element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocument/Overview/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/VB/source.vb" id="Snippet1"::: @@ -512,7 +509,6 @@ Where the DTD file contains the following: ## Examples The following example clones the root node of the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.Clone Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/Clone/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.Clone Example/VB/source.vb" id="Snippet1"::: @@ -601,7 +597,6 @@ Where the DTD file contains the following: ## Examples The following example shows the difference between a deep and shallow clone. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.CloneNode Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/CloneNode/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.CloneNode Example/VB/source.vb" id="Snippet1"::: @@ -671,7 +666,6 @@ Where the DTD file contains the following: ## Examples The following example loads and edits an XML document before performing an XSLT transform. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTransform.Transform2/CPP/trans_snip.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/CreateNavigator/trans_snip.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform2/VB/trans_snip.vb" id="Snippet1"::: @@ -745,7 +739,6 @@ Where the DTD file contains the following: ## Examples The following example displays the title element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.FirstChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/FirstChild/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.FirstChild Example/VB/source.vb" id="Snippet1"::: @@ -810,7 +803,6 @@ Where the DTD file contains the following: ## Examples The following example displays all the books in the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetEnumerator Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/GetEnumerator/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.GetEnumerator Example/VB/source.vb" id="Snippet1"::: @@ -880,7 +872,6 @@ Where the DTD file contains the following: ## Examples The following example adds a new attribute to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/Attributes/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/VB/source.vb" id="Snippet1"::: @@ -946,7 +937,6 @@ Where the DTD file contains the following: ## Examples The following example adds a new element to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetPrefixOfNamespace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/GetPrefixOfNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.GetPrefixOfNamespace Example/VB/source.vb" id="Snippet1"::: @@ -1009,7 +999,6 @@ Where the DTD file contains the following: ## Examples The following example displays all the child nodes of the root element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocument/Overview/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/VB/source.vb" id="Snippet1"::: @@ -1075,7 +1064,6 @@ Where the DTD file contains the following: ## Examples The following example compares the `InnerText` and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/InnerText/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/VB/source.vb" id="Snippet1"::: @@ -1152,7 +1140,6 @@ d. ## Examples The following example compares the and `InnerXml` properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/InnerText/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/VB/source.vb" id="Snippet1"::: @@ -1234,7 +1221,6 @@ d. ## Examples The following example adds a new node to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertAfter Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/InsertAfter/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.InsertAfter Example/VB/source.vb" id="Snippet1"::: @@ -1325,7 +1311,6 @@ d. ## Examples The following example adds a new node to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertBefore Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/InsertBefore/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.InsertBefore Example/VB/source.vb" id="Snippet1"::: @@ -1482,7 +1467,6 @@ d. ## Examples The following example displays the title element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.this Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/Item/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.this Example/VB/source.vb" id="Snippet1"::: @@ -1616,7 +1600,6 @@ d. ## Examples The following example displays the price element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.LastChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocument/Overview/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.LastChild Example/VB/source.vb" id="Snippet1"::: @@ -1976,7 +1959,6 @@ d. ## Examples The following example displays all the books in the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.NextSibling Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocument/Overview/source4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.NextSibling Example/VB/source.vb" id="Snippet1"::: @@ -2142,7 +2124,6 @@ d. ## Examples The following example compares output from the and `OuterXml` properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.OuterXml Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/OuterXml/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.OuterXml Example/VB/source.vb" id="Snippet1"::: @@ -2450,7 +2431,6 @@ d. ## Examples The following example adds a new node to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PrependChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/PrependChild/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.PrependChild Example/VB/source.vb" id="Snippet1"::: @@ -2525,7 +2505,6 @@ d. ## Examples The following example displays all the books in the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PreviousSibling Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlLinkedNode/PreviousSibling/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.PreviousSibling Example/VB/source.vb" id="Snippet1"::: @@ -2653,7 +2632,6 @@ d. ## Examples The following example removes all child and attribute nodes from the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveAll Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/RemoveAll/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.RemoveAll Example/VB/source.vb" id="Snippet1"::: @@ -2717,7 +2695,6 @@ d. ## Examples The following example removes a node from the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/RemoveChild/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.RemoveChild Example/VB/source.vb" id="Snippet1"::: @@ -2791,7 +2768,6 @@ d. ## Examples The following example replaces the title element in the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.ReplaceChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/ReplaceChild/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.ReplaceChild Example/VB/source.vb" id="Snippet1"::: @@ -2981,7 +2957,6 @@ nodeList = root.SelectNodes("//book[contains(title,""'Emma'"")]") ## Examples The following example selects all books where the author's last name is Austen, and then changes the price of those books. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectNodes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocument/Overview/source6.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.SelectNodes Example/VB/source.vb" id="Snippet1"::: @@ -3108,7 +3083,6 @@ nodeList = root.SelectNodes("//ab:book[contains(ab:title,""'Emma'"")]", nsmgr) ## Examples The following example displays the values of each of the ISBN attributes. This example uses an object, which inherits from the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlNode.SelectNodes1/CPP/selectnodes1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/SelectNodes/selectnodes1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlNode.SelectNodes1/VB/selectnodes1.vb" id="Snippet1"::: @@ -3145,7 +3119,6 @@ nodeList = root.SelectNodes("//ab:book[contains(ab:title,""'Emma'"")]", nsmgr) ## Examples The following example returns the first book with the matching author name. The `XmlNamespaceManager` resolves the default namespace in the XPath expression. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode2/CPP/XmlNode.SelectSingleNode2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/SelectSingleNode/selectsingnode2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlNode.SelectSingleNode2/VB/selectsingnode2.vb" id="Snippet1"::: @@ -3244,7 +3217,6 @@ book = root.SelectSingleNode("descendant::book[title=""'Emma'""]") ## Examples The following example changes the price of the first Jane Austen book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectSingleNode Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/SelectSingleNode/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.SelectSingleNode Example/VB/source.vb" id="Snippet1"::: @@ -3369,7 +3341,6 @@ book = root.SelectSingleNode("descendant::ab:book[ab:title=""'Emma'""]", nsmgr) ## Examples The following example selects the book with the matching ISBN value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode1/CPP/selectsingnode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/SelectSingleNode/selectsingnode.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlNode.SelectSingleNode1/VB/selectsingnode.vb" id="Snippet1"::: @@ -3691,7 +3662,6 @@ book = root.SelectSingleNode("descendant::ab:book[ab:title=""'Emma'""]", nsmgr) ## Examples The following example adds a new attribute to the XML document and sets the property of the new attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/Attributes/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/VB/source.vb" id="Snippet1"::: @@ -3758,7 +3728,6 @@ book = root.SelectSingleNode("descendant::ab:book[ab:title=""'Emma'""]", nsmgr) ## Examples The following example displays the contents of the root node to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteContentTo Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/WriteContentTo/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.WriteContentTo Example/VB/source.vb" id="Snippet1"::: @@ -3824,7 +3793,6 @@ book = root.SelectSingleNode("descendant::ab:book[ab:title=""'Emma'""]", nsmgr) ## Examples The following example displays the root node to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteTo Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/WriteTo/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.WriteTo Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlNodeChangedEventHandler.xml b/xml/System.Xml/XmlNodeChangedEventHandler.xml index 7f3610f242f..4d77b572f49 100644 --- a/xml/System.Xml/XmlNodeChangedEventHandler.xml +++ b/xml/System.Xml/XmlNodeChangedEventHandler.xml @@ -66,24 +66,23 @@ An containing the event data. Represents the method that handles , , , , and events. - diff --git a/xml/System.Xml/XmlNodeList.xml b/xml/System.Xml/XmlNodeList.xml index 6681b2df939..3940256750e 100644 --- a/xml/System.Xml/XmlNodeList.xml +++ b/xml/System.Xml/XmlNodeList.xml @@ -70,19 +70,19 @@ Represents an ordered collection of nodes. - collection was created from are immediately reflected in the nodes returned by the `XmlNodeList` properties and methods. `XmlNodeList` supports iteration and indexed access. - - `XmlNodeList` is returned by the following properties and methods. - -- - Returns an `XmlNodeList` containing all the children of the node. - -- - Returns an `XmlNodeList` containing a collection of nodes matching the XPath query. - -- `GetElementsByTagName` - Returns an `XmlNodeList` containing a list of all descendant elements that match the specified name. This method is available in both the and classes. - + collection was created from are immediately reflected in the nodes returned by the `XmlNodeList` properties and methods. `XmlNodeList` supports iteration and indexed access. + + `XmlNodeList` is returned by the following properties and methods. + +- - Returns an `XmlNodeList` containing all the children of the node. + +- - Returns an `XmlNodeList` containing a collection of nodes matching the XPath query. + +- `GetElementsByTagName` - Returns an `XmlNodeList` containing a list of all descendant elements that match the specified name. This method is available in both the and classes. + ]]> Ordered Node Retrieval by Index @@ -181,19 +181,18 @@ Gets the number of nodes in the . The number of nodes in the . - object and uses the method and the resulting `XmlNodeList` to display all the book titles. + object and uses the method and the resulting `XmlNodeList` to display all the book titles. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/GetElementsByTagName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: - - The example uses the file `2books.xml` as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: + + The example uses the file `2books.xml` as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -246,24 +245,23 @@ Gets an enumerator that iterates through the collection of nodes. An enumerator used to iterate through the collection of nodes. - @@ -317,15 +315,14 @@ Retrieves a node at the given index. The with the specified index in the collection. If is greater than or equal to the number of nodes in the list, this returns . - @@ -389,19 +386,18 @@ Gets a node at the given index. The with the specified index in the collection. If index is greater than or equal to the number of nodes in the list, this returns . - object and uses the method and the resulting `XmlNodeList` to display all the book titles. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp" id="Snippet1"::: + object and uses the method and the resulting `XmlNodeList` to display all the book titles. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/GetElementsByTagName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: - - The example uses the file `2books.xml` as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: + + The example uses the file `2books.xml` as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: + ]]> diff --git a/xml/System.Xml/XmlNodeReader.xml b/xml/System.Xml/XmlNodeReader.xml index 58283892266..597055325b5 100644 --- a/xml/System.Xml/XmlNodeReader.xml +++ b/xml/System.Xml/XmlNodeReader.xml @@ -191,7 +191,6 @@ Output: ## Examples The following example reads all the attributes on the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/VB/source.vb" id="Snippet1"::: @@ -252,7 +251,6 @@ Output: ## Examples The following example parses a file and displays the base URI of each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.BaseURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/BaseURI/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.BaseURI Example/VB/source.vb" id="Snippet1"::: @@ -422,7 +420,6 @@ Output: ## Examples The following example parses a file and closes the reader. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -674,7 +671,6 @@ This method does not move the reader. ## Examples The following example gets the value of the ISBN attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.GetAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/GetAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.GetAttribute Example/VB/source.vb" id="Snippet1"::: @@ -820,7 +816,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example reads all the attributes on the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/VB/source.vb" id="Snippet1"::: @@ -894,7 +889,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example displays the value for every node that can have a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.HasValue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/HasValue/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.HasValue Example/VB/source.vb" id="Snippet1"::: @@ -1015,7 +1009,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example displays the text content of each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/IsEmptyElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/VB/source.vb" id="Snippet1"::: @@ -1196,7 +1189,6 @@ This property does not move the reader. ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/VB/source.vb" id="Snippet1"::: @@ -1339,7 +1331,6 @@ This property does not move the reader. ## Examples The following example reads all the attributes on the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/VB/source.vb" id="Snippet1"::: @@ -1527,7 +1518,6 @@ This property does not move the reader. ## Examples The following example reads all the attributes on the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/VB/source.vb" id="Snippet1"::: @@ -1588,7 +1578,6 @@ This property does not move the reader. ## Examples The following example gets the value of the first attribute of the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToFirstAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/MoveToFirstAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToFirstAttribute Example/VB/source.vb" id="Snippet1"::: @@ -1651,7 +1640,6 @@ This property does not move the reader. ## Examples The following example reads a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToNextAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/MoveToNextAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToNextAttribute Example/VB/source.vb" id="Snippet1"::: @@ -1730,7 +1718,6 @@ This property does not move the reader. ## Examples The following example reads an XML and displays each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -1795,7 +1782,6 @@ This property does not move the reader. ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/VB/source.vb" id="Snippet1"::: @@ -1907,7 +1893,6 @@ This property does not move the reader. ## Examples The following example reads an XML and displays each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -1970,7 +1955,6 @@ This property does not move the reader. ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/VB/source.vb" id="Snippet1"::: @@ -2075,7 +2059,6 @@ This property does not move the reader. ## Examples The following example reads an XML and displays each node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -2146,7 +2129,6 @@ This property does not move the reader. ## Examples The following example reads an attribute with text and entity reference nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ReadAttributeValue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/ReadAttributeValue/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.ReadAttributeValue Example/VB/source.vb" id="Snippet1"::: @@ -2578,7 +2560,6 @@ This property does not move the reader. ## Examples The following example displays the text content of each of the elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/IsEmptyElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/VB/source.vb" id="Snippet1"::: @@ -2642,7 +2623,6 @@ This property does not move the reader. ## Examples The following example uses `ResolveEntity` to expand a general entity. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ResolveEntity Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/ResolveEntity/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.ResolveEntity Example/VB/source.vb" id="Snippet1"::: @@ -2779,7 +2759,6 @@ This property does not move the reader. ## Examples The following example reads the price element node in the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Skip Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Skip/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Skip Example/VB/source.vb" id="Snippet1"::: @@ -3030,7 +3009,6 @@ This property does not move the reader. ## Examples The following example reads an XML and displays each node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlNotation.xml b/xml/System.Xml/XmlNotation.xml index 1aedf327d34..8748cbd16f0 100644 --- a/xml/System.Xml/XmlNotation.xml +++ b/xml/System.Xml/XmlNotation.xml @@ -146,13 +146,13 @@ Gets the markup representing the children of this node. For nodes, String.Empty is returned. - Attempting to set the property. @@ -196,17 +196,17 @@ Gets a value indicating whether the node is read-only. - if the node is read-only; otherwise, . - + if the node is read-only; otherwise, . + Because nodes are read-only, this property always returns . - @@ -303,19 +303,18 @@ Gets the name of the current node. The name of the notation. - @@ -360,19 +359,18 @@ Gets the type of the current node. The node type. For nodes, the value is XmlNodeType.Notation. - @@ -423,11 +421,11 @@ Gets the markup representing this node and all its children. For nodes, String.Empty is returned. - @@ -482,19 +480,18 @@ Gets the value of the public identifier on the notation declaration. The public identifier on the notation. If there is no public identifier, is returned. - @@ -550,19 +547,18 @@ Gets the value of the system identifier on the notation declaration. The system identifier on the notation. If there is no system identifier, is returned. - @@ -610,11 +606,11 @@ The to which you want to save. Saves the children of the node to the specified . This method has no effect on nodes. - @@ -661,11 +657,11 @@ The to which you want to save. Saves the node to the specified . This method has no effect on nodes. - diff --git a/xml/System.Xml/XmlReader.xml b/xml/System.Xml/XmlReader.xml index 6f5ce6beeff..0e631e139fe 100644 --- a/xml/System.Xml/XmlReader.xml +++ b/xml/System.Xml/XmlReader.xml @@ -3282,7 +3282,6 @@ public class Sample ## Examples This is useful when you want to write code that can skip over random XML markup without breaking. For example, suppose you have the following code: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.MoveToContent Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlReader/MoveToContent/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlReader.MoveToContent Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlReaderSettings.xml b/xml/System.Xml/XmlReaderSettings.xml index 691ed383a31..04bf4437a6a 100644 --- a/xml/System.Xml/XmlReaderSettings.xml +++ b/xml/System.Xml/XmlReaderSettings.xml @@ -144,7 +144,6 @@ The following example creates an that uses an is processing text data, it always checks tha object and the method to associate a schema with an XML document. The schema is added to the property of the object. The value of the property is an object. The schema is used to validate that the XML document conforms to the schema content model. Schema validation errors and warnings are handled by the defined in the object. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaSetOverall Example/CPP/xmlschemasetexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlReaderSettings/Schemas/xmlschemasetexample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaSetOverall Example/VB/xmlschemasetexample.vb" id="Snippet1"::: @@ -1601,7 +1594,6 @@ The output is as follows: ## Examples The following example validates using a schema stored in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlReaderSettings/ValidationType/validschemaset.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlReader_Validate_SchemaSet/VB/validschemaset.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlSecureResolver.xml b/xml/System.Xml/XmlSecureResolver.xml index d68dd196201..fb8902d6b5f 100644 --- a/xml/System.Xml/XmlSecureResolver.xml +++ b/xml/System.Xml/XmlSecureResolver.xml @@ -126,7 +126,6 @@ See the constructor reference topics for examples of these types of restrictions ## Examples The following example constructs an object by using a customized permission set. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.cctor/CPP/secresolver.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlSecureResolver/.ctor/secresolver.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSecureResolver.cctor/VB/secresolver.vb" id="Snippet1"::: @@ -348,7 +347,6 @@ See the constructor reference topics for examples of these types of restrictions ## Examples The following example uses an with default credentials to resolve and open network resources needed by the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.Credentials/CPP/secresolver2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlSecureResolver/Credentials/secresolver2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSecureResolver.Credentials/VB/secresolver2.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlSignificantWhitespace.xml b/xml/System.Xml/XmlSignificantWhitespace.xml index 9340733ee93..c8de3b71085 100644 --- a/xml/System.Xml/XmlSignificantWhitespace.xml +++ b/xml/System.Xml/XmlSignificantWhitespace.xml @@ -64,11 +64,11 @@ Represents white space between markup in a mixed content node or white space within an xml:space= 'preserve' scope. This is also referred to as significant white space. - @@ -128,11 +128,11 @@ The object. Initializes a new instance of the class. - @@ -186,13 +186,13 @@ Creates a duplicate of this node. The cloned node. - . - - The cloned node has no parent. returns `null`. - + . + + The cloned node has no parent. returns `null`. + ]]> @@ -333,15 +333,14 @@ Gets the type of the current node. For nodes, this value is XmlNodeType.SignificantWhitespace. - @@ -501,11 +500,11 @@ Gets or sets the value of the node. The white space characters found in the node. - Setting to invalid white space characters. @@ -558,11 +557,11 @@ The to which you want to save. Saves all the children of the node to the specified . - @@ -614,11 +613,11 @@ The to which you want to save. Saves the node to the specified . - diff --git a/xml/System.Xml/XmlTextReader.xml b/xml/System.Xml/XmlTextReader.xml index f1d0a82c8d6..87185ba5447 100644 --- a/xml/System.Xml/XmlTextReader.xml +++ b/xml/System.Xml/XmlTextReader.xml @@ -240,7 +240,6 @@ ## Examples The following example loads an XML string into the `XmlTextReader` object using the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.cctor1/CPP/rdrcctor1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/rdrcctor1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.cctor1/VB/rdrcctor1.vb" id="Snippet1"::: @@ -324,7 +323,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example reads an XML file and displays each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -1003,7 +1001,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example parses an XML fragment. It uses the `XmlParserContext` and its to handle namespace resolution. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.Cctor/CPP/readfrag.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/readfrag.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.Cctor/VB/readfrag.vb" id="Snippet1"::: @@ -1070,7 +1067,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example displays all attributes on the current node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/VB/source.vb" id="Snippet1"::: @@ -1133,7 +1129,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example displays the base URI for each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.BaseURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/BaseURI/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.BaseURI Example/VB/source.vb" id="Snippet1"::: @@ -1411,7 +1406,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example displays each node including its depth, line number, and line position. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/Depth/readlinenum.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.LineNum/VB/readlinenum.vb" id="Snippet1"::: @@ -1799,7 +1793,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example gets the value of the ISBN attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetAttribute1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/GetAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.GetAttribute1 Example/VB/source.vb" id="Snippet1"::: @@ -2019,7 +2012,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example reads the first part of an XML document and then uses `GetRemainder` to complete reading the document using a second reader. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetRemainder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/GetRemainder/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.GetRemainder Example/VB/source.vb" id="Snippet1"::: @@ -2153,7 +2145,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example displays the value for every node that can have a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.HasValue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/HasValue/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.HasValue Example/VB/source.vb" id="Snippet1"::: @@ -2281,7 +2272,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example displays the text content of each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/IsEmptyElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/VB/source.vb" id="Snippet1"::: @@ -2457,7 +2447,6 @@ If the reader is positioned on a `DocumentType` node, this method can be used to ## Examples The following example displays each node including its depth, line number, and line position. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/Depth/readlinenum.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.LineNum/VB/readlinenum.vb" id="Snippet1"::: @@ -2533,7 +2522,6 @@ abc ## Examples The following example displays each node including its depth, line number, and line position. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/Depth/readlinenum.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.LineNum/VB/readlinenum.vb" id="Snippet1"::: @@ -2595,7 +2583,6 @@ abc ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/VB/source.vb" id="Snippet1"::: @@ -2755,7 +2742,6 @@ abc ## Examples The following example displays all attributes on the current node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/VB/source.vb" id="Snippet1"::: @@ -2946,7 +2932,6 @@ abc ## Examples The following example displays all attributes on the current node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/VB/source.vb" id="Snippet1"::: @@ -3008,7 +2993,6 @@ abc ## Examples The following example gets the value of the first attribute of the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToFirstAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/MoveToFirstAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToFirstAttribute Example/VB/source.vb" id="Snippet1"::: @@ -3076,7 +3060,6 @@ abc ## Examples The following example displays all attributes on the current node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.HasAttributes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/MoveToNextAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlReader.HasAttributes Example/VB/source.vb" id="Snippet1"::: @@ -3156,7 +3139,6 @@ abc ## Examples The following example reads an XML file and displays each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -3279,7 +3261,6 @@ abc ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/VB/source.vb" id="Snippet1"::: @@ -3399,7 +3380,6 @@ abc ## Examples The following example reads an XML file and displays each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -3487,7 +3467,6 @@ abc ## Examples The following example shows reader behavior with normalization turned on and then off. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.Normalization/CPP/readnormal.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/Normalization/readnormal.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.Normalization/VB/readnormal.vb" id="Snippet1"::: @@ -3548,7 +3527,6 @@ abc ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/VB/source.vb" id="Snippet1"::: @@ -3737,7 +3715,6 @@ abc ## Examples The following example reads an XML file and displays each node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -3811,7 +3788,6 @@ abc ## Examples The following example reads an attribute with text and entity nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.ReadAttributeValue/CPP/readattrval.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/ReadAttributeValue/readattrval.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.ReadAttributeValue/VB/readattrval.vb" id="Snippet1"::: @@ -3881,7 +3857,6 @@ abc ## Examples The following example reads a file containing Base64 and BinHex data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/ReadBase64/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/VB/source.vb" id="Snippet1"::: @@ -3960,7 +3935,6 @@ abc ## Examples The following example reads a file containing `Base64` and `BinHex` data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/ReadBase64/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/VB/source.vb" id="Snippet1"::: @@ -4081,7 +4055,6 @@ if (XmlNodeType.Element == reader.NodeType && "thing" == reader.Name) ## Examples The following example reads in XML using `ReadChars`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadChars Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/ReadChars/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.ReadChars Example/VB/source.vb" id="Snippet1"::: @@ -4524,7 +4497,6 @@ if (XmlNodeType.Element == reader.NodeType && "thing" == reader.Name) ## Examples The following example displays the text content of each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/IsEmptyElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/VB/source.vb" id="Snippet1"::: @@ -4605,7 +4577,6 @@ if (XmlNodeType.Element == reader.NodeType && "thing" == reader.Name) ## Examples The following example parses two XML documents in a single stream. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.ResetState/CPP/resetstate.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/ResetState/resetstate.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.ResetState/VB/resetstate.vb" id="Snippet1"::: @@ -5044,7 +5015,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example reads an XML file and displays each node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -5112,7 +5082,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example reads an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.WhitespaceHandling Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/WhitespaceHandling/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.WhitespaceHandling Example/VB/source.vb" id="Snippet1"::: @@ -5184,7 +5153,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example displays the `xml:lang` value for each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlLang/CPP/readlang.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/XmlLang/readlang.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.XmlLang/VB/readlang.vb" id="Snippet1"::: @@ -5263,7 +5231,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example uses the `XmlResolver` property to specify the credentials necessary to access the networked file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlResolver/CPP/rdr_resolver.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/XmlResolver/rdr_resolver.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.XmlResolver/VB/rdr_resolver.vb" id="Snippet1"::: @@ -5327,7 +5294,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example parses a file and returns significant white space if an `xml:space='preserve'` scope is found. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlSpace/CPP/readspace.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/XmlSpace/readspace.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.XmlSpace/VB/readspace.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlTextWriter.xml b/xml/System.Xml/XmlTextWriter.xml index 20fa1a11814..043afe2a880 100644 --- a/xml/System.Xml/XmlTextWriter.xml +++ b/xml/System.Xml/XmlTextWriter.xml @@ -372,7 +372,6 @@ ## Examples The following example writes an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/VB/source.vb" id="Snippet1"::: @@ -433,7 +432,6 @@ ## Examples The following example writes out two XML fragments. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextWriter.Flush/CPP/write2docs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/Flush/write2docs.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextWriter.Flush/VB/write2docs.vb" id="Snippet1"::: @@ -524,7 +522,6 @@ XmlTextWriter w = new XmlTextWriter(Console.Out); ## Examples The following example writes an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/VB/source.vb" id="Snippet1"::: @@ -607,7 +604,6 @@ tw.WriteDocType(name, pubid, sysid, subset); ## Examples The following example writes an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/VB/source.vb" id="Snippet1"::: @@ -744,7 +740,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/LookupPrefix/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/VB/source.vb" id="Snippet1"::: @@ -931,7 +926,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example encodes an input file using `WriteBase64` and generates a temporary XML file. The temporary XML file is decoded using the method and compared to the original file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteBase64/CPP/writebase64.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteBase64/writebase64.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteBase64/VB/writebase64.vb" id="Snippet1"::: @@ -1065,7 +1059,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1131,7 +1124,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example uses the `WriteCharEntity` method to write an email address. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteTimeSpan Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCharEntity/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteTimeSpan Example/VB/source.vb" id="Snippet1"::: @@ -1275,7 +1267,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1358,7 +1349,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1428,7 +1418,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/LookupPrefix/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/VB/source.vb" id="Snippet1"::: @@ -1487,7 +1476,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1555,7 +1543,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteEndElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteEndElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteEndElement Example/VB/source.vb" id="Snippet1"::: @@ -1617,7 +1604,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1685,7 +1671,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes out an element with no content. It uses WriteFullEndElement to write the full end element tag. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteFullEndElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteFullEndElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteFullEndElement Example/VB/source.vb" id="Snippet1"::: @@ -1871,7 +1856,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1978,7 +1962,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes out a portion of a XSD schema. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteQualifiedName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteQualifiedName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteQualifiedName Example/VB/source.vb" id="Snippet1"::: @@ -2069,7 +2052,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes a string using the `WriteRaw` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteRaw1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteRaw/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteRaw1 Example/VB/source.vb" id="Snippet1"::: @@ -2218,7 +2200,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/LookupPrefix/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/VB/source.vb" id="Snippet1"::: @@ -2312,7 +2293,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -2449,7 +2429,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/LookupPrefix/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/VB/source.vb" id="Snippet1"::: @@ -2573,7 +2552,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/VB/source.vb" id="Snippet1"::: @@ -2703,7 +2681,6 @@ writer.WriteStartElement("root"); ## Examples The following example uses the `WriteWhitespace` method to control how the file is formatted. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteWhitespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/VB/source.vb" id="Snippet1"::: @@ -2843,7 +2820,6 @@ writer.WriteStartElement("root"); ## Examples The following example uses the `WriteWhitespace` method to control how the file is formatted. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteWhitespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlUrlResolver.xml b/xml/System.Xml/XmlUrlResolver.xml index 9a5f3ebde45..86cd54a6f4a 100644 --- a/xml/System.Xml/XmlUrlResolver.xml +++ b/xml/System.Xml/XmlUrlResolver.xml @@ -50,48 +50,48 @@ Resolves external XML resources named by a Uniform Resource Identifier (URI). - is used to resolve external XML resources such as entities, document type definitions (DTDs) or schemas. It is also used to process include and import elements found in Extensible StyleSheet Language (XSL) style sheets or XML Schema definition language (XSD) schemas. - - is the default resolver for all classes in the namespace. It supports the `file://` and `http://` protocols and requests from the class. - + is used to resolve external XML resources such as entities, document type definitions (DTDs) or schemas. It is also used to process include and import elements found in Extensible StyleSheet Language (XSL) style sheets or XML Schema definition language (XSD) schemas. + + is the default resolver for all classes in the namespace. It supports the `file://` and `http://` protocols and requests from the class. + > [!IMPORTANT] -> objects can contain sensitive information such as user credentials. You should be careful when you cache objects and should not pass objects to an untrusted component. - -## Resolving DTDs - If an XML reader () is reading an XML file that contains an external DTD, it calls the method to get a stream representation of the DTD. If the URI of the DTD is a relative URI, the XML reader calls the method and returns an absolute URI for the given `relativeUri` and `baseURi` parameters. If the doesn't know how to resolve the URI, it returns `null`. - - The method uses the information in the property as appropriate to gain access to the resource. There is no `get` accessor to this property for security reasons. When overwriting , **GetEntity** is the method that utilizes the credential information in the **Credentials** property. - - Resolving all other XML resources is very similar to resolving DTDs. negotiates the connection with the external resource and returns a representation of the content. The object that is making the call to interprets the stream. - -## Extending the XmlUrlResolver class - The default behavior of the class is to resolve an XML data resource from its source, not from cache. In some cases, resolving a data resource from cache can improve the performance of an application by saving a trip to the data resource's server. The performance gains here must be weighed against the need for up-to-date content. - - The following example extends and builds a new class, `XmlCachingResolver`, to retrieve resources from the cache. This is done by overriding the property and the method. - +> objects can contain sensitive information such as user credentials. You should be careful when you cache objects and should not pass objects to an untrusted component. + +## Resolving DTDs + If an XML reader () is reading an XML file that contains an external DTD, it calls the method to get a stream representation of the DTD. If the URI of the DTD is a relative URI, the XML reader calls the method and returns an absolute URI for the given `relativeUri` and `baseURi` parameters. If the doesn't know how to resolve the URI, it returns `null`. + + The method uses the information in the property as appropriate to gain access to the resource. There is no `get` accessor to this property for security reasons. When overwriting , **GetEntity** is the method that utilizes the credential information in the **Credentials** property. + + Resolving all other XML resources is very similar to resolving DTDs. negotiates the connection with the external resource and returns a representation of the content. The object that is making the call to interprets the stream. + +## Extending the XmlUrlResolver class + The default behavior of the class is to resolve an XML data resource from its source, not from cache. In some cases, resolving a data resource from cache can improve the performance of an application by saving a trip to the data resource's server. The performance gains here must be weighed against the need for up-to-date content. + + The following example extends and builds a new class, `XmlCachingResolver`, to retrieve resources from the cache. This is done by overriding the property and the method. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlUrlResolver/Overview/XmlCachingResolver_ex.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlCachingResolver_ex/VB/XmlCachingResolver_ex.vb" id="Snippet1"::: - - The caching behavior of the `XmlCachingResolver` class is implemented in the `GetEntity` method. This is done by creating new and objects. The object is created using the member of the enumeration. - - The property of the object is set with the object. - - An instance of the `XmlCachingResolver` class is created with the `Boolean` `enableHttpCaching`. When this value is set to `true`, the instance resolves a resource from the default cache if possible. When `enableHttpCaching` is set to `false`, the instance uses the default behavior and resolves resources from their source. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlCachingResolver_ex/VB/XmlCachingResolver_ex.vb" id="Snippet1"::: + + The caching behavior of the `XmlCachingResolver` class is implemented in the `GetEntity` method. This is done by creating new and objects. The object is created using the member of the enumeration. + + The property of the object is set with the object. + + An instance of the `XmlCachingResolver` class is created with the `Boolean` `enableHttpCaching`. When this value is set to `true`, the instance resolves a resource from the default cache if possible. When `enableHttpCaching` is set to `false`, the instance uses the default behavior and resolves resources from their source. + > [!NOTE] -> This example leverages the extensibility of the XML classes in the .NET Framework. Other classes can be extended and customized to suit the needs of a particular application. - - - -## Examples - The following example creates an that uses an with default credentials. - +> This example leverages the extensibility of the XML classes in the .NET Framework. Other classes can be extended and customized to suit the needs of a particular application. + + + +## Examples + The following example creates an that uses an with default credentials. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlUrlResolver/Overview/XmlResolver_Samples.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlResolver_Samples/VB/XmlResolver_Samples.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlResolver_Samples/VB/XmlResolver_Samples.vb" id="Snippet1"::: + ]]> XML Documents and Data @@ -238,32 +238,32 @@ Sets credentials used to authenticate web requests. The credentials to be used to authenticate web requests. If this property is not set, the value defaults to ; that is, the has no user credentials. - property to a credential cache. - -```csharp -NetworkCredential myCred = new NetworkCredential(UserName,SecurelyStoredPassword,Domain); -CredentialCache myCache = new CredentialCache(); -myCache.Add(new Uri("http://www.contoso.com/"), "Basic", myCred); -myCache.Add(new Uri("http://app.contoso.com/"), "Basic", myCred); -XmlUrlResolver resolver = new XmlUrlResolver(); -resolver.Credentials = myCache; -``` - - - -## Examples - The following example creates an object with credentials. The uses the credentials on the object to access a network resource. - + property to a credential cache. + +```csharp +NetworkCredential myCred = new NetworkCredential(UserName,SecurelyStoredPassword,Domain); +CredentialCache myCache = new CredentialCache(); +myCache.Add(new Uri("http://www.contoso.com/"), "Basic", myCred); +myCache.Add(new Uri("http://app.contoso.com/"), "Basic", myCred); +XmlUrlResolver resolver = new XmlUrlResolver(); +resolver.Credentials = myCache; +``` + + + +## Examples + The following example creates an object with credentials. The uses the credentials on the object to access a network resource. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlUrlResolver/Overview/XmlResolver_Samples.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlResolver_Samples/VB/XmlResolver_Samples.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlResolver_Samples/VB/XmlResolver_Samples.vb" id="Snippet2"::: + ]]> @@ -325,25 +325,24 @@ resolver.Credentials = myCache; Maps a URI to an object that contains the actual resource. A stream object or if a type other than stream is specified. - . - + . + > [!IMPORTANT] -> Your application can mitigate memory denial of service threats to the method by implementing IStream to limit the number of bytes read. This helps guard against situations where malicious code attempts to pass an infinite stream of bytes to the method. - - +> Your application can mitigate memory denial of service threats to the method by implementing IStream to limit the number of bytes read. This helps guard against situations where malicious code attempts to pass an infinite stream of bytes to the method. + + + +## Examples + The following example demonstrates the `GetEntity` and methods. -## Examples - The following example demonstrates the `GetEntity` and methods. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlUrlResolver/GetEntity/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -523,11 +522,11 @@ resolver.Credentials = myCache; Resolves the absolute URI from the base and relative URIs. The absolute URI, or if the relative URI cannot be resolved. - diff --git a/xml/System.Xml/XmlWhitespace.xml b/xml/System.Xml/XmlWhitespace.xml index 91a2fe19f2a..9d5ea9c1f7d 100644 --- a/xml/System.Xml/XmlWhitespace.xml +++ b/xml/System.Xml/XmlWhitespace.xml @@ -64,11 +64,11 @@ Represents white space in element content. - @@ -128,11 +128,11 @@ The object. Initializes a new instance of the class. - @@ -186,13 +186,13 @@ Creates a duplicate of this node. The cloned node. - serves as a copy constructor for nodes. To see how this method behaves with other node types, see . - - The cloned node has no parent. returns `null`. - + serves as a copy constructor for nodes. To see how this method behaves with other node types, see . + + The cloned node has no parent. returns `null`. + ]]> @@ -333,15 +333,14 @@ Gets the type of the node. For nodes, the value is . - @@ -501,11 +500,11 @@ Gets or sets the value of the node. The white space characters found in the node. - Setting to invalid white space characters. @@ -558,11 +557,11 @@ The to which you want to save. Saves all the children of the node to the specified . - @@ -614,11 +613,11 @@ The to which you want to save. Saves the node to the specified . - diff --git a/xml/System.Xml/XmlWriter.xml b/xml/System.Xml/XmlWriter.xml index d33382fd843..776a3cf7b1f 100644 --- a/xml/System.Xml/XmlWriter.xml +++ b/xml/System.Xml/XmlWriter.xml @@ -199,7 +199,6 @@ ## Examples The following example writes an XML node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Close/writeelems.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.Close/VB/writeelems.vb" id="Snippet1"::: @@ -1251,7 +1250,6 @@ An method was called before a previous asy ## Examples The following example writes two XML fragments. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.Flush/CPP/write2docs_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Flush/write2docs_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.Flush/VB/write2docs_v2.vb" id="Snippet1"::: @@ -1371,7 +1369,6 @@ An asynchronous method was called without ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/LookupPrefix/writeelemstring_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteElementString/VB/writeelemstring_v2.vb" id="Snippet1"::: @@ -1549,7 +1546,6 @@ This member may behave differently when it is used in a Portable Class Library p ## Examples The following example copies all the elements to the output, changes the tag names to upper case, and copies all the attributes unchanged. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributes/CPP/writeattrs_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/WriteAttributes/writeattrs_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteAttributes/VB/writeattrs_v2.vb" id="Snippet1"::: @@ -1729,7 +1725,6 @@ An asynchronous method was called without ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/LookupPrefix/writeelemstring_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteElementString/VB/writeelemstring_v2.vb" id="Snippet1"::: @@ -1826,7 +1821,6 @@ An method was called before a previous asy ## Examples The following example uses the method to write a namespace declaration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributeString/CPP/writeattrstring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/WriteAttributeString/writeattrstring.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteAttributeString/VB/writeattrstring.vb" id="Snippet1"::: @@ -1919,7 +1913,6 @@ An method was called before a previous asy ## Examples The following example uses the method to write a namespace declaration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributeString/CPP/writeattrstring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/WriteAttributeString/writeattrstring.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteAttributeString/VB/writeattrstring.vb" id="Snippet1"::: @@ -3105,7 +3098,6 @@ An asynchronous method was called without ## Examples The following example uses several write methods to create an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/LookupPrefix/writeelemstring_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteElementString/VB/writeelemstring_v2.vb" id="Snippet1"::: @@ -3187,7 +3179,6 @@ An asynchronous method was called without ## Examples The following example uses several write methods to create an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/LookupPrefix/writeelemstring_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteElementString/VB/writeelemstring_v2.vb" id="Snippet1"::: @@ -4353,7 +4344,6 @@ while (!reader.EOF){ ## Examples The following example writes the first and last book nodes out to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteNode/CPP/writenode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/WriteNode/writenode.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteNode/VB/writenode.vb" id="Snippet1"::: @@ -5940,7 +5930,6 @@ An asynchronous method was called without ## Examples The following example writes an XML node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Close/writeelems.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.Close/VB/writeelems.vb" id="Snippet1"::: @@ -6111,7 +6100,6 @@ An method was called before a previous asy ## Examples The following example writes out an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/LookupPrefix/writeelemstring_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteElementString/VB/writeelemstring_v2.vb" id="Snippet1"::: @@ -6325,7 +6313,6 @@ test<item>test ## Examples The following example writes an XML node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Close/writeelems.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.Close/VB/writeelems.vb" id="Snippet1":::