We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Serialization: Not sure how to serialize whole thing

Thread ID:

Created:

Updated:

Platform:

Replies:

77833 Nov 18,2008 10:44 PM UTC Nov 19,2008 08:32 AM UTC Windows Forms 1
loading
Tags: Diagram
Administrator [Syncfusion]
Asked On November 18, 2008 10:44 PM UTC

Hi. I provided the code i wrote below for a custom dynamic node.

It contains a few properties.

However, when I save (via serialization), my property values are not saved.

Please advise as to how to proceed.

Thanks


[code]
_
Public Class Narrationtool : Inherits Group


Private m_outerRect As Syncfusion.Windows.Forms.Diagram.Rectangle = Nothing
Private m_textNode As TextNode = Nothing
Private m_strDescription As String = "Custom Symbol"

Public ztype As String = "Narration"
Private _LocW As String
Private _LocX As String
Private _LocY As String
Private _LocZ As String
Private _Data As String
Private _Music As String
Private _Background As String
Private _Character As String
Private _PermaFlag As String
Private _PermaStory As String
Private _Go2 As String
Private _ComeFrom As String
Private _connectionstatus As String
Private _XtraVar1 As String
Private _XtraVar2 As String
Private _XtraVar3 As String
Public Property connectionstatus() As String
Get
Return _connectionstatus
End Get
Set(ByVal value As String)
_connectionstatus = value
End Set
End Property

Public Property ComeFrom() As String
Get
Return _ComeFrom
End Get
Set(ByVal value As String)
_ComeFrom = value
End Set
End Property

Public Property locW() As String
Get
Return _locW
End Get
Set(ByVal value As String)
_locW = value
End Set
End Property

Public Property LocX() As String
Get
Return _LocX
End Get
Set(ByVal value As String)
_LocX = value
End Set
End Property

Public Property LocY() As String
Get
Return _LocY
End Get
Set(ByVal value As String)
_LocY = value
End Set
End Property

Public Property locZ() As String
Get
Return _locZ
End Get
Set(ByVal value As String)
_locZ = value
End Set
End Property



Public Property data() As String
Get
Return _data
End Get
Set(ByVal value As String)
_data = value
End Set
End Property

Public Property music() As String
Get
Return _music
End Get
Set(ByVal value As String)
_music = value
End Set
End Property

Public Property background() As String
Get
Return _background
End Get
Set(ByVal value As String)
_background = value
End Set
End Property

Public Property character() As String
Get
Return _character
End Get
Set(ByVal value As String)
_character = value
End Set
End Property

Public Property permaflag() As String
Get
Return _permaflag
End Get
Set(ByVal value As String)
_permaflag = value
End Set
End Property

Public Property permastory() As String
Get
Return _permastory
End Get
Set(ByVal value As String)
_permastory = value
End Set
End Property

Public Property go2() As String
Get
Return _go2
End Get
Set(ByVal value As String)
_go2 = value
End Set
End Property

Public Property xtravar1() As String
Get
Return _xtravar1
End Get
Set(ByVal value As String)
_xtravar1 = value
End Set
End Property

Public Property xtravar2() As String
Get
Return _xtravar2
End Get
Set(ByVal value As String)
_xtravar2 = value
End Set
End Property

Public Property xtravar3() As String
Get
Return _xtravar3
End Get
Set(ByVal value As String)
_xtravar3 = value
End Set
End Property


Public Sub New()
Me.m_outerRect = New Syncfusion.Windows.Forms.Diagram.Rectangle(0, 0, 86, 20)
Me.m_outerRect.Name = "Rectangle"
Me.m_outerRect.FillStyle.Type = Syncfusion.Windows.Forms.Diagram.FillStyleType.LinearGradient
Me.m_outerRect.FillStyle.ForeColor = System.Drawing.Color.Orange
Me.m_outerRect.FillStyle.Color = Color.Orange
Me.m_outerRect.ShadowStyle.Visible = True
Me.m_outerRect.EditStyle.AllowSelect = False
Me.AppendChild(m_outerRect)

Me.m_textNode = New TextNode("Narration")
Me.m_textNode.FontStyle.Size = 15
Dim size As New Size(86, 20)
Dim sizeF As SizeF
sizeF = size.op_Implicit(size)
Me.m_textNode.Size = sizeF
Me.m_textNode.PinPoint = New PointF(43, 10)
Me.m_textNode.EditStyle.AllowSelect = False
Me.AppendChild(m_textNode)
Me.zType = "Narration"
End Sub

Public Sub New(ByVal src As Narrationtool)
MyBase.New(src)
' update reference
m_outerRect = CType(Me.GetChild(0), Syncfusion.Windows.Forms.Diagram.Rectangle)
m_textNode = CType(Me.GetChild(1), TextNode)
End Sub

'''
''' Serialization constructor for symbols.
'''

''' Serialization state information
''' Streaming context information
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New(info, context)
Me.m_strDescription = info.GetString("strDescription")
End Sub
'''
''' This property provides an example of adding a member variable to a custom symbol
''' and demonstrates how to handle serialization for this property.
'''

_
Public Property Description() As String
Get
Return Me.m_strDescription
End Get
Set(ByVal value As String)
Me.m_strDescription = value
End Set
End Property
'''
''' Populates a SerializationInfo with the data needed to
''' serialize the target object.
'''

''' SerializationInfo object to populate
''' Destination streaming context
Protected Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.GetObjectData(info, context)

' Additional member variables are serialized here
info.AddValue("strDescription", Me.m_strDescription)
End Sub

Public Overrides Function Clone() As Object
Return New Narrationtool(Me)
End Function

End Class
[/code]



Administrator [Syncfusion]
Replied On November 19, 2008 08:32 AM UTC

Ok.

I've gone about it doing:
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New(info, context)
Me.m_strDescription = info.GetString("strDescription")
Me.ztype = info.GetString("connectionstatus") 'Do this for each property, the name in quotes must match in the GetObjectData, also use the correct datatype when using Get, even thou all your properties are strings...
Me._LocW = info.GetString("locw")
Me._LocX = info.GetString("locx")
Me._LocY = info.GetString("locy")
Me._LocZ = info.GetString("locz")
Me._Data = info.GetString("data")
Me._Music = info.GetString("music")
Me._Background = info.GetString("background")
Me._Character = info.GetString("character")
Me._PermaFlag = info.GetString("permaflag")
Me._PermaStory = info.GetString("permastory")
Me._Go2 = info.GetString("go2")
Me._ComeFrom = info.GetString("comefrom")
Me._XtraVar1 = info.GetString("xtravar1")
Me._XtraVar2 = info.GetString("xtravar2")
Me._XtraVar3 = info.GetString("xtravar3")
End Sub

Protected Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.GetObjectData(info, context)

' ' Additional member variables are serialized here
info.AddValue("strDescription", Me.m_strDescription)
info.AddValue("connectionstatus", Me._connectionstatus) 'Add the properties here, make sure names match between two subs
info.AddValue("locw", Me._LocW)
info.AddValue("locx", Me._LocX)
info.AddValue("locy", Me._LocY)
info.AddValue("locz", Me._LocZ)
info.AddValue("data", Me._Data)
info.AddValue("music", Me._Music)
info.AddValue("character", Me._Character)
info.AddValue("background", Me._Background)
info.AddValue("permaflag", Me._PermaFlag)
info.AddValue("permastory", Me._PermaStory)
info.AddValue("go2", Me._Go2)
info.AddValue("comefrom", Me._ComeFrom)
info.AddValue("xtravar1", Me._XtraVar1)
info.AddValue("xtravar2", Me._XtraVar2)
info.AddValue("xtravar3", Me._XtraVar3)

End Sub

Now working ^__^


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;