USER CONTROL

LORDAUTUNM 17/10/2013 16:05:35
#430127
Boa tarde no VB6 tinhamos UserControl_ReadProperties(ByVal PropBag As PropertyBag) e UserControl_WriteProperties(ByVal PropBag As PropertyBag) como ficou isso no .net
JULIOSTEINERT 18/10/2013 10:33:31
#430145
Buenas... usei esta classe para resolver...

Imports System
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Runtime.Serialization
Imports System.IO

<Serializable()> Public Class PropertyBag
Inherits MarshalByRefObject

[ô]Collection that holds all the objects
Private objCon As New Collection

[ô]Description : To add the specified object to the Propertybag
[ô]param name [Ô]szobjDesc[Ô] : Description of the object
[ô]param name [Ô]objValue[Ô] : Object

Public Sub WriteProperty(ByVal szobjDesc As String, ByVal objValue As Object, Optional ByVal DefaultValue As Object = [Ô][Ô])

objCon.Add(objValue, szobjDesc, DefaultValue)

End Sub

[ô]Description : To read the specified object from the Propertybag
[ô]param name [Ô]szobjDesc[Ô] : Description of the object
[ô]param name [Ô]ObjDefValue[Ô] : Default value
[ô]Return value : Object
Public Function ReadProperty(ByVal szobjDesc As String, Optional ByVal ObjDefValue As Object = Nothing) As Object

If objCon.Contains(szobjDesc) = True Then
Return objCon.Item(szobjDesc)
Else
Return ObjDefValue
End If

End Function

[ô]Description : To Get or Set the contents of the propertybag
Public Property Contents()

Get

Dim objMemStream As New MemoryStream
Dim objFormatter As New BinaryFormatter

[ô]Serialize the Collection to binary using BinaryFormatter and
[ô]store it in Memory Stream
objFormatter.Serialize(objMemStream, objCon)

[ô]Return the value in Memory Stream as byte array
Return objMemStream.ToArray()

End Get

Set(ByVal value As Object)

Dim objMemStream As MemoryStream
Dim objFormatter As New BinaryFormatter

[ô]Clear the Existing Collection
objCon.Clear()

[ô]Populate the byte array assigned to a Memory Stream
objMemStream = New MemoryStream(CType(value, Byte()))

[ô]Deserialize from the Memory Stream and Store that in Collection
objCon = objFormatter.Deserialize(objMemStream)

End Set

End Property

[ô]Description : Clears the PropertyBag
Public Sub Clear()

objCon.Clear()

End Sub

End Class
AGRADECER ENGRANDECE O SER HUMANO....
julio steinert
Tópico encerrado , respostas não são mais permitidas