Structure and Class

S

shapper

Hello,

I have a class which I am using in my profile.
I made this class Serializable by using:

<Serializable()> _
Public Class Options

One of the properties in this class is of type Level where level is a
structure:

Public Structure Level
Dim Delete As Boolean
Dim Create As Boolean
Dim Update As Boolean
Dim View As Boolean
End Structure ' Level

' Access
Private _Access As Level
Public Property Access() As Level
Get
Return _Access
End Get
Set(ByVal value As Level)
_Access = value
End Set
End Property ' Access

Can I make this?

I am not sure if I can use the structure as described since my class
is Serializable because of profile.

Should I turn Level into a Serializable class to with 4 properties?

Thanks,
Miguel
 
M

MasterGaurav \(www.edujini-labs.com\)

Public Structure Level
Dim Delete As Boolean
Dim Create As Boolean
Dim Update As Boolean
Dim View As Boolean
End Structure ' Level
Should I turn Level into a Serializable class to with 4 properties?

Why not make it a simple enum with Flags!

<Flags> Public Enum Level
Delete = 1
Create = 2
Update = 4
View = 8
End Enum

IMHO, this would be a better choice for you!


--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
 
K

Kevin Spencer

You can use a structure, certainly. However, private members of classes and
structures are not serialized as XML.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
S

shapper

You can use a structure, certainly. However, private members of classes and
structures are not serialized as XML.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net

Hi,

I am serializing my profile classes as binary:
<add allowAnonymous = "false" name = "Collaborator" type =
"Collaborator" serializeAs = "Binary" />

And my class is as follows (I am using the <flag> enum sugestion from
Gaurav):

<Serializable()> _
Public Class Collaborator

' Permissions
Private _Permissions As Security
Public Property Permissions() As Security
Get
Return _Permissions
End Get
Set(ByVal value As Security)
_Permissions = value
End Set
End Property ' Permissions

' Security
<Serializable()> _
Public Class Security

' Level
<Flags()> Public Enum Level
Delete = 1
Create = 2
Update = 4
View = 8
End Enum ' Level

' Blogger
Private _Blogger As Level
Public Property Blogger() As Level
Get
Return _Blogger
End Get
Set(ByVal value As Level)
_Blogger = value
End Set
End Property ' Blogger

' Scheduler
Private _Scheduler As Level
Public Property Scheduler() As Level
Get
Return _Scheduler
End Get
Set(ByVal value As Level)
_Scheduler = value
End Set
End Property ' Scheduler
...

End Class ' Security

End Class ' Collaborator

Is this ok?

Thanks,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top