Here are the new methods added to KartrisWebHelperBLL i'll post that later when it has datasets added
Public Shared Function Serialize(ByVal strObject As Object) As String
Dim strType As String = strObject.GetType.ToString.ToLower
Debug.Print(strType)
If strType = "system.data.datatable" Then
Return SerializeTableToString(strObject)
Else
Dim oXS As XmlSerializer = New XmlSerializer(strObject.GetType)
Dim oStrW As New StringWriter()
'Serialize the object into an XML string
oXS.Serialize(oStrW, strObject)
Serialize = oStrW.ToString()
oStrW.Close()
End If
End Function
Public Shared Function SerializeTableToString(ptable As DataTable) As String
If ptable Is Nothing Then
Return Nothing
Else
Using sw = New StringWriter()
Using tw = New XmlTextWriter(sw)
' Must set name for serialization to succeed.
ptable.TableName = "results"
tw.Formatting = Formatting.Indented
tw.WriteStartDocument()
tw.WriteStartElement("KartrisdataTable")
DirectCast(ptable, Serialization.IXmlSerializable).WriteXml(tw)
tw.WriteEndElement()
tw.WriteEndDocument()
tw.Flush()
tw.Close()
sw.Flush()
Return sw.ToString()
End Using
End Using
End If
End Function