File tree Expand file tree Collapse file tree 2 files changed +11
-20
lines changed 
csharp/VS_Snippets_CLR/HowToSignXMLDocumentRSA/cs 
visualbasic/VS_Snippets_CLR/HowToSignXMLDocumentRSA/vb Expand file tree Collapse file tree 2 files changed +11
-20
lines changed Original file line number Diff line number Diff line change 66
77public  class  SignXML 
88{ 
9- 
109    public  static   void  Main ( String [ ]  args ) 
1110    { 
1211        try 
@@ -41,27 +40,23 @@ public static void Main(String[] args)
4140            // <snippet13> 
4241            xmlDoc . Save ( "test.xml" ) ; 
4342            // </snippet13> 
44- 
45- 
46- 
4743        } 
4844        catch  ( Exception  e ) 
4945        { 
5046            Console . WriteLine ( e . Message ) ; 
5147        } 
5248    } 
5349
54- 
5550    // Sign an XML file.  
5651    // This document cannot be verified unless the verifying  
5752    // code has the key with which it was signed. 
58-     public  static   void  SignXml ( XmlDocument  xmlDoc ,  RSA  key ) 
53+     public  static   void  SignXml ( XmlDocument  xmlDoc ,  RSA  rsaKey ) 
5954    { 
6055        // Check arguments. 
6156        if  ( xmlDoc  ==  null ) 
62-             throw  new  ArgumentException ( " xmlDoc" ) ; 
63-         if  ( key  ==  null ) 
64-             throw  new  ArgumentException ( "key" ) ; 
57+             throw  new  ArgumentException ( nameof ( xmlDoc ) ) ; 
58+         if  ( rsaKey  ==  null ) 
59+             throw  new  ArgumentException ( nameof ( rsaKey ) ) ; 
6560
6661        // Create a SignedXml object. 
6762        // <snippet5> 
@@ -70,7 +65,7 @@ public static void SignXml(XmlDocument xmlDoc, RSA key)
7065
7166        // Add the key to the SignedXml document. 
7267        // <snippet6> 
73-         signedXml . SigningKey  =  key ; 
68+         signedXml . SigningKey  =  rsaKey ; 
7469        // </snippet6> 
7570
7671        // <snippet7> 
@@ -105,7 +100,6 @@ public static void SignXml(XmlDocument xmlDoc, RSA key)
105100        // <snippet12> 
106101        xmlDoc . DocumentElement . AppendChild ( xmlDoc . ImportNode ( xmlDigitalSignature ,  true ) ) ; 
107102        // </snippet12> 
108- 
109103    } 
110104} 
111105// </snippet1> 
Original file line number Diff line number Diff line change @@ -33,32 +33,29 @@ Module SignXML
3333            ' <snippet13> 
3434            xmlDoc.Save( "test.xml" ) 
3535            ' </snippet13> 
36- 
37- 
3836        Catch  e  As  Exception 
3937            Console.WriteLine(e.Message) 
4038        End  Try 
41- 
4239    End  Sub 
4340
4441    ' Sign an XML file.  
4542    ' This document cannot be verified unless the verifying  
4643    ' code has the key with which it was signed. 
47-     Sub  SignXml( ByVal  xmlDoc  As  XmlDocument,  ByVal  key  As  RSA) 
44+     Sub  SignXml( ByVal  xmlDoc  As  XmlDocument,  ByVal  rsaKey  As  RSA) 
4845        ' Check arguments. 
4946        If  xmlDoc  Is  Nothing  Then 
50-             Throw  New  ArgumentException( " xmlDoc" ) 
47+             Throw  New  ArgumentException( NameOf ( xmlDoc) )
5148        End  If 
52-         If  key  Is  Nothing  Then 
53-             Throw  New  ArgumentException( "key" ) 
49+         If  rsaKey  Is  Nothing  Then 
50+             Throw  New  ArgumentException( NameOf (rsaKey) )
5451        End  If 
5552        ' Create a SignedXml object. 
5653        ' <snippet5> 
5754        Dim  signedXml  As  New  SignedXml(xmlDoc) 
5855        ' </snippet5> 
5956        ' Add the key to the SignedXml document. 
6057        ' <snippet6> 
61-         signedXml.SigningKey  =  key 
58+         signedXml.SigningKey  =  rsaKey 
6259        ' </snippet6> 
6360        ' <snippet7> 
6461        ' Create a reference to be signed. 
@@ -89,4 +86,4 @@ Module SignXML
8986        ' </snippet12> 
9087    End  Sub 
9188End  Module 
92- ' </snippet1> 
89+ ' </snippet1> 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments