@@ -9,19 +9,20 @@ Module SignXML
9
9
' Create a new CspParameters object to specify
10
10
' a key container.
11
11
' <snippet2>
12
- Dim cspParams As New CspParameters()
13
- cspParams.KeyContainerName = "XML_DSIG_RSA_KEY"
12
+ Dim cspParams As New CspParameters With {
13
+ .KeyContainerName = "XML_DSIG_RSA_KEY"
14
+ }
14
15
' </snippet2>
15
16
' Create a new RSA signing key and save it in the container.
16
17
' <snippet3>
17
18
Dim rsaKey As New RSACryptoServiceProvider(cspParams)
18
19
' </snippet3>
19
20
' Create a new XML document.
20
21
' <snippet4>
21
- Dim xmlDoc As New XmlDocument()
22
-
23
22
' Load an XML file into the XmlDocument object.
24
- xmlDoc.PreserveWhitespace = True
23
+ Dim xmlDoc As New XmlDocument With {
24
+ .PreserveWhitespace = True
25
+ }
25
26
xmlDoc.Load( "test.xml" )
26
27
' </snippet4>
27
28
' Sign the XML document.
@@ -44,10 +45,12 @@ Module SignXML
44
45
Sub SignXml( ByVal xmlDoc As XmlDocument, ByVal rsaKey As RSA)
45
46
' Check arguments.
46
47
If xmlDoc Is Nothing Then
47
- Throw New ArgumentException( NameOf (xmlDoc))
48
+ Throw New ArgumentException(
49
+ "The XML doc cannot be nothing." , NameOf (xmlDoc))
48
50
End If
49
51
If rsaKey Is Nothing Then
50
- Throw New ArgumentException( NameOf (rsaKey))
52
+ Throw New ArgumentException(
53
+ "The RSA key cannot be nothing." , NameOf (rsaKey))
51
54
End If
52
55
' Create a SignedXml object.
53
56
' <snippet5>
0 commit comments