我有一个可序列化的类
<Serializable()> Public Class SACCVar
Private _ConsigneCompression As Integer
Public Event VariableChanged(ByVal Val As Object, ByVal Old_Val As Object, desc As String)
Public Property ConsigneCompression As Integer
Get
Return _ConsigneCompression
End Get
Set(value As Integer)
Tmp_Val = _ConsigneCompression
_ConsigneCompression = value
RaiseEvent VariableChanged(_ConsigneCompression, Tmp_Val, "ConsigneCompression")
End Set
End Property End Class
在一个模块中,我将我的变量声明为类并实现我的 raise 函数
Public WithEvents MesuresVal As New MesuresVar
Public Sub SaccVarChanged(ByVal Val, ByVal Old_Value, DictKeyDesc) Handles SaccData.VariableChanged
For Each item As CtrlItem In SaccData.DicOfControl(DictKeyDesc)
Dim pinstance As PropertyInfo = item.Ctrl.GetType.GetProperty(item.prop)
pinstance.SetValue(item.Ctrl, Val)
Next End Sub
在我做的代码中
SaccData.ConsigneCompression = 1234
它调用 SaccVarChanged
但是当我调用反序列化我的类的子例程时,它会传递我的“公共属性”中代码的 RaiseEvent VariableChanged 部分。但它没有提高 SaccVarChanged 子。
有什么我可以做的吗?谢谢
编辑:这是我的序列化/反序列化代码:
Dim fichier As String
fichier = Fichier_SACC
' Déclaration
Dim XSSACC As New XmlSerializer(SaccData.GetType)
Dim streamSACC As FileStream
If Not File.Exists(fichier) Then
'Exit Sub
'TODO gestion erreur
Else
streamSACC = New FileStream(fichier, FileMode.Open)
Try
SaccData = CType(XSSACC.Deserialize(streamSACC), SACCVar)
Catch ex As Exception
' Propagrer l'exception
Throw ex
Finally
' En cas d'erreur, n'oublier pas de fermer le flux en lecture si ce dernier est toujours ouvert
streamSACC.Close()
End Try
End If
Dim StreamSACC As New StreamWriter(Fichier_SACC)
Dim serialiseSACC As New XmlSerializer(SaccData.GetType)
Try
serialiseSACC.Serialize(StreamSACC, SaccData)
Catch ex As Exception
Throw ex
Finally
StreamSACC.Close()
End Try