Imports System
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlTypes
Imports Microsoft.SqlServer.Server

Imports System.IO

Partial Public Class UserDefinedFunctions
Public Shared Function CompressBytes _
(ByVal UnCompressedBytes As SqlBytes, ByVal CompressMethod As Byte) As SqlBytes
Try
Dim output As New MemoryStream
CompressWrapper.Compress(New MemoryStream (UnCompressedBytes.Value), output, _
CType (CompressMethod, eCompressMethod))
Return New SqlBytes(output.ToArray)
Catch ex As Exception
Throw ex
Finally
'
End Try
End Function

Public Shared Function DeCompressBytes _
(ByVal CompressedBytes As SqlBytes, ByVal CompressMethod As Byte) As SqlBytes
Try
Dim output As New MemoryStream
CompressWrapper.Decompress(New MemoryStream (CompressedBytes.Value), output, _
CType (CompressMethod, eCompressMethod))
Return New SqlBytes(output.ToArray)
Catch ex As Exception
Throw ex
Finally
'
End Try
End Function

End Class