Skip to content

Commit bd8eb93

Browse files
ChrisMaddockmairaw
authored andcommitted
Add code types to snippets (dotnet#167)
1 parent 1f50b5a commit bd8eb93

13 files changed

+86
-86
lines changed

xml/System.Xml/IFragmentCapableXmlDictionaryWriter.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="IFragmentCapableXmlDictionaryWriter" FullName="System.Xml.IFragmentCapableXmlDictionaryWriter">
1+
<Type Name="IFragmentCapableXmlDictionaryWriter" FullName="System.Xml.IFragmentCapableXmlDictionaryWriter">
22
<TypeSignature Language="C#" Value="public interface IFragmentCapableXmlDictionaryWriter" />
33
<TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IFragmentCapableXmlDictionaryWriter" />
44
<TypeSignature Language="DocId" Value="T:System.Xml.IFragmentCapableXmlDictionaryWriter" />
@@ -191,7 +191,7 @@
191191
192192
## Examples
193193
194-
```
194+
```csharp
195195
MemoryStream stream = new MemoryStream();
196196
MemoryStream fragmentStream = new MemoryStream();
197197
XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream);

xml/System.Xml/IHasXmlNode.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="IHasXmlNode" FullName="System.Xml.IHasXmlNode">
1+
<Type Name="IHasXmlNode" FullName="System.Xml.IHasXmlNode">
22
<TypeSignature Language="C#" Value="public interface IHasXmlNode" />
33
<TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IHasXmlNode" />
44
<TypeSignature Language="DocId" Value="T:System.Xml.IHasXmlNode" />
@@ -78,7 +78,7 @@
7878
## Remarks
7979
The following C# code uses `GetNode` to access a node the <xref:System.Xml.XPath.XPathNavigator> is currently positioned on.
8080
81-
```
81+
```csharp
8282
XmlDocument doc = new XmlDocument();
8383
doc.Load("books.xml");
8484
XPathNavigator nav = doc.CreateNavigator();

xml/System.Xml/XmlConvert.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="XmlConvert" FullName="System.Xml.XmlConvert">
1+
<Type Name="XmlConvert" FullName="System.Xml.XmlConvert">
22
<TypeSignature Language="C#" Value="public class XmlConvert" />
33
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit XmlConvert extends System.Object" />
44
<TypeSignature Language="DocId" Value="T:System.Xml.XmlConvert" />
@@ -40,7 +40,7 @@
4040
4141
You can use the <xref:System.Xml.XmlConvert.EncodeName%2A> method with the <xref:System.Xml.XmlWriter> class to ensure the names being written are valid XML names. The following C# code converts the name "Order Detail" into a valid XML name and writes the element `<Order_0x0020_Detail>My order</Order_0x0020_Detail>`.
4242
43-
```
43+
```csharp
4444
writer.WriteElementString(XmlConvert.EncodeName("Order Detail"),"My order");
4545
4646
```
@@ -964,7 +964,7 @@ writer.WriteElementString(XmlConvert.EncodeName("Order Detail"),"My order");
964964
965965
The example uses the transactions.xml file.
966966
967-
```
967+
```xml
968968
<?xml version="1.0"?>
969969
<transactions>
970970
<transaction>
@@ -1038,7 +1038,7 @@ writer.WriteElementString(XmlConvert.EncodeName("Order Detail"),"My order");
10381038
10391039
The example uses the transactions.xml file.
10401040
1041-
```
1041+
```xml
10421042
<?xml version="1.0"?>
10431043
<transactions>
10441044
<transaction>
@@ -1112,7 +1112,7 @@ writer.WriteElementString(XmlConvert.EncodeName("Order Detail"),"My order");
11121112
11131113
The example uses the transactions.xml file.
11141114
1115-
```
1115+
```xml
11161116
<?xml version="1.0"?>
11171117
<transactions>
11181118
<transaction>
@@ -2579,7 +2579,7 @@ writer.WriteElementString(XmlConvert.EncodeName("Order Detail"),"My order");
25792579
## Remarks
25802580
This method can be used with the <xref:System.Xml.XmlWriter> class in the following manner.
25812581
2582-
```
2582+
```csharp
25832583
try{
25842584
writer.WriteStartElement(XmlConvert.VerifyName("item"),"bar");
25852585
}
@@ -2688,7 +2688,7 @@ catch(Exception e)
26882688
## Remarks
26892689
This method ensures that the name token follows the proper syntax for a valid NMTOKEN. It can be used in the following manner:
26902690
2691-
```
2691+
```csharp
26922692
try {
26932693
writer.WriteStartElement(XmlConvert.VerifyNMTOKEN("abc"),"book");
26942694
}
@@ -2792,7 +2792,7 @@ catch(Exception e) {
27922792
## Remarks
27932793
This method ensures that the name token follows the proper syntax for a valid token. It can be used in the following manner:
27942794
2795-
```
2795+
```csharp
27962796
try {
27972797
writer.WriteStartElement(XmlConvert.VerifyTOKEN("abc"),"book");
27982798
}

xml/System.Xml/XmlDataDocument.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="XmlDataDocument" FullName="System.Xml.XmlDataDocument">
1+
<Type Name="XmlDataDocument" FullName="System.Xml.XmlDataDocument">
22
<TypeSignature Language="C#" Value="public class XmlDataDocument : System.Xml.XmlDocument" />
33
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit XmlDataDocument extends System.Xml.XmlDocument" />
44
<TypeSignature Language="DocId" Value="T:System.Xml.XmlDataDocument" />
@@ -193,7 +193,7 @@
193193
## Remarks
194194
`Note to Inheritors` If you overload this function, it cannot be used for extensibility. Instead, you can return an element created by the base class, in this case, `XmlDataDocument`. See the following example.
195195
196-
```
196+
```csharp
197197
class MyXmlDataDocument : XmlDataDocument {
198198
public override XmlElement CreateElement(string prefix, string localName, string nsURI) {
199199
//Ensure we are returning the base class implementation of element.
@@ -640,13 +640,13 @@ class MyXmlDataDocument : XmlDataDocument {
640640
641641
If the current node and its following siblings look similar to the following:
642642
643-
```
643+
```xml
644644
<!--comment--><element1>one</element1><element2>two</element2>
645645
```
646646
647647
`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:
648648
649-
```
649+
```xml
650650
<!--comment--><?process
651651
instruction?><!--comment--></endtag>
652652
```

xml/System.Xml/XmlDictionaryWriter.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="XmlDictionaryWriter" FullName="System.Xml.XmlDictionaryWriter">
1+
<Type Name="XmlDictionaryWriter" FullName="System.Xml.XmlDictionaryWriter">
22
<TypeSignature Language="C#" Value="public abstract class XmlDictionaryWriter : System.Xml.XmlWriter" />
33
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract beforefieldinit XmlDictionaryWriter extends System.Xml.XmlWriter" />
44
<TypeSignature Language="DocId" Value="T:System.Xml.XmlDictionaryWriter" />
@@ -124,7 +124,7 @@
124124
## Remarks
125125
The binary format only supports one text node as the attribute value and therefore buffers the values written to it to emit a single node, as shown in the following sample code.
126126
127-
```
127+
```csharp
128128
XmlWriter binarywriter = XmlDictionaryWriter.CreateBinaryWriter(Stream.Null);
129129
binarywriter.WriteStartAttribute("StartAttribute");
130130
string largeStr = new string('r', 100000);

xml/System.Xml/XmlDocument.xml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="XmlDocument" FullName="System.Xml.XmlDocument">
1+
<Type Name="XmlDocument" FullName="System.Xml.XmlDocument">
22
<TypeSignature Language="C#" Value="public class XmlDocument : System.Xml.XmlNode" />
33
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit XmlDocument extends System.Xml.XmlNode" />
44
<TypeSignature Language="DocId" Value="T:System.Xml.XmlDocument" />
@@ -1062,7 +1062,7 @@
10621062
## Remarks
10631063
The following C# code
10641064
1065-
```
1065+
```csharp
10661066
XmlElement elem;
10671067
elem=doc.CreateElement("xy:item", "urn:abc");
10681068
```
@@ -1127,7 +1127,7 @@ elem=doc.CreateElement("xy:item", "urn:abc");
11271127
## Remarks
11281128
The following C# code
11291129
1130-
```
1130+
```csharp
11311131
XmlElement elem;
11321132
elem=doc.CreateElement("xy", "item", "urn:abc");
11331133
```
@@ -2412,7 +2412,7 @@ elem=doc.CreateElement("xy", "item", "urn:abc");
24122412
24132413
`InnerXml` removes redundant namespace declarations. As a result, numerous cut and paste operations do not increase the size of your document with redundant namespace declarations. Consider the following XSL document:
24142414
2415-
```
2415+
```xml
24162416
<xsl:stylesheet version="1.0"
24172417
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
24182418
<xsl:template match="stock">
@@ -2423,7 +2423,7 @@ elem=doc.CreateElement("xy", "item", "urn:abc");
24232423
24242424
The `InnerXml` property on the stylesheet node returns the following string:
24252425
2426-
```
2426+
```xml
24272427
<xsl:template match="stock"
24282428
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
24292429
...
@@ -2434,42 +2434,42 @@ elem=doc.CreateElement("xy", "item", "urn:abc");
24342434
24352435
If you move `InnerXml` from a document with no default namespace to a document with a default namespace, the behavior is a little different. Consider the following XML string:
24362436
2437-
```
2437+
```xml
24382438
<test>
24392439
<item>123</item>
24402440
</test>
24412441
```
24422442
24432443
`InnerXml` returns a plain XML string with no namespace declarations:
24442444
2445-
```
2445+
```xml
24462446
<item>123</item>
24472447
```
24482448
24492449
If you then insert this string into a document that does have a default namespace, such as the following:
24502450
2451-
```
2451+
```xml
24522452
<test2 xmlns="urn:1">
24532453
</test>
24542454
```
24552455
24562456
`InnerXml` parses the string in context, and the new nodes pick up the urn:1 namespace. The result looks like this:
24572457
2458-
```
2458+
```xml
24592459
<test2 xmlns="urn:1">
24602460
<item>123</item>
24612461
</test>
24622462
```
24632463
24642464
Now when you ask for the `InnerXml` you get back the following:
24652465
2466-
```
2466+
```xml
24672467
<item xmlns="urn:1">123</item>
24682468
```
24692469
24702470
If you explicitly want the inserted item to preserve the fact that it came from a document that had no namespace then you need to manually add an xmlns= "" declaration and insert the resulting string:
24712471
2472-
```
2472+
```xml
24732473
<item xmlns="">123</item>
24742474
```
24752475
@@ -2797,13 +2797,13 @@ elem=doc.CreateElement("xy", "item", "urn:abc");
27972797
27982798
If the current node and its siblings look like the following:
27992799
2800-
```
2800+
```xml
28012801
<!--comment--><element1>one</element1><element2>two</element2>
28022802
```
28032803
28042804
`Load` throws an exception because a document cannot have two root level elements. If the current node and its siblings look like the following:
28052805
2806-
```
2806+
```xml
28072807
<!--comment--><?process instruction?><!--comment--></endtag>
28082808
```
28092809
@@ -3488,7 +3488,7 @@ elem=doc.CreateElement("xy", "item", "urn:abc");
34883488
34893489
`ReadNode` can also read attributes, but in this case it does not advance the reader to the next attribute. This allows you to write the following C# code:
34903490
3491-
```
3491+
```csharp
34923492
XmlDocument doc = new XmlDocument();
34933493
while (reader.MoveToNextAttribute())
34943494
{
@@ -3577,7 +3577,7 @@ while (reader.MoveToNextAttribute())
35773577
35783578
When the document is saved, xmlns attributes are generated to persist the node identity (local name + namespace URI) correctly. For example, the following C# code
35793579
3580-
```
3580+
```csharp
35813581
XmlDocument doc = new XmlDocument();
35823582
doc.AppendChild(doc.CreateElement("item","urn:1"));
35833583
doc.Save(Console.Out);
@@ -3683,7 +3683,7 @@ doc.Save(Console.Out);
36833683
36843684
When the document is saved, xmlns attributes are generated to persist the node identity (local name + namespace URI) correctly. For example, the following C# code
36853685
3686-
```
3686+
```csharp
36873687
XmlDocument doc = new XmlDocument();
36883688
doc.AppendChild(doc.CreateElement("item","urn:1"));
36893689
doc.Save(Console.Out);
@@ -3755,15 +3755,15 @@ doc.Save(Console.Out);
37553755
37563756
When the document is saved, xmlns attributes are generated to persist the node identity (LocalName + NamespaceURI) correctly. For example, the following C# code
37573757
3758-
```
3758+
```csharp
37593759
XmlDocument doc = new XmlDocument();
37603760
doc.AppendChild(doc.CreateElement("item","urn:1"));
37613761
doc.Save(Console.Out);
37623762
```
37633763
37643764
generates this xmls attribute:
37653765
3766-
```
3766+
```xml
37673767
<item
37683768
xmls="urn:1"/>
37693769
```

xml/System.Xml/XmlEntity.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="XmlEntity" FullName="System.Xml.XmlEntity">
1+
<Type Name="XmlEntity" FullName="System.Xml.XmlEntity">
22
<TypeSignature Language="C#" Value="public class XmlEntity : System.Xml.XmlNode" />
33
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit XmlEntity extends System.Xml.XmlNode" />
44
<TypeSignature Language="DocId" Value="T:System.Xml.XmlEntity" />
@@ -63,7 +63,7 @@
6363
6464
The value of this property varies depending on the node type. Nodes which are children of external EntityReference nodes return the location of the entity itself. For example, consider the following XML document:
6565
66-
```
66+
```xml
6767
<!DOCTYPE item [
6868
<!ENTITY xyz SYSTEM "a/b.xml">
6969
]>
@@ -89,7 +89,7 @@
8989
9090
As a second example, given the following XML document:
9191
92-
```
92+
```xml
9393
<!DOCTYPE Mydata SYSTEM "http://localhost/doctype.dtd">
9494
<baa>&xyz;</baa>
9595
```

xml/System.Xml/XmlNamespaceManager.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="XmlNamespaceManager" FullName="System.Xml.XmlNamespaceManager">
1+
<Type Name="XmlNamespaceManager" FullName="System.Xml.XmlNamespaceManager">
22
<TypeSignature Language="C#" Value="public class XmlNamespaceManager : System.Collections.IEnumerable, System.Xml.IXmlNamespaceResolver" />
33
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit XmlNamespaceManager extends System.Object implements class System.Collections.IEnumerable, class System.Xml.IXmlNamespaceResolver" />
44
<TypeSignature Language="DocId" Value="T:System.Xml.XmlNamespaceManager" />
@@ -337,7 +337,7 @@ while (reader.Read())
337337
## Remarks
338338
The following code shows how to use the <xref:System.Collections.IEnumerator> to view all the namespace pairs stored in the <xref:System.Xml.XmlNamespaceManager> object.
339339
340-
```
340+
```vb
341341
Dim nsEnum As IEnumerator = nsmgr.GetEnumerator()
342342
Do While nsEnum.MoveNext
343343
If nsEnum.Current <> "" Then

0 commit comments

Comments
 (0)