Table of Contents Previous Next
Logo
Client-Side Slice-to-Visual Basic Mapping : 18.17 Using Slice Checksums
Copyright © 2003-2007 ZeroC, Inc.

18.17 Using Slice Checksums

As described in Section 4.20, the Slice compilers can optionally generate check­sums of Slice definitions. For slice2vb, the checksum option causes the compiler to generate checksums in each VB source file that are added to a member of the Ice.SliceChecksums class:
Namespace Ice
    Public NotInheritable Class SliceChecksums
        Public Readonly Shared checksums As SliceChecksumDict 
    End Class
End Namespace
The checksums map is initialized automatically prior to first use; no action is required by the application.
In order to verify a server’s checksums, a client could simply compare the dictionaries using the Equals function. However, this is not feasible if it is possible that the server might be linked with more Slice definitions than the client. A more general solution is to iterate over the local checksums as demonstrated below:
Dim serverChecksums As Ice.SliceChecksumDict = ...
For Each e As System.Collections.DictionaryEntry _
        In Ice.SliceChecksums.checksums
    Dim checksum As String = serverChecksums(e.Key)
    If checksum Is Nothing Then
        ' No match found for type id!
    ElseIf Not checksum.Equals(e.Value) Then
        ' Checksum mismatch!
    End If
Next
In this example, the client first verifies that the server’s dictionary contains an entry for each Slice type ID, and then it proceeds to compare the checksums.
Table of Contents Previous Next
Logo