Thursday, March 22, 2012

Structure and Class

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,
MiguelPublic Structure Level

Quote:

Originally Posted by

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


Quote:

Originally Posted by

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


Why not make it a simple enum with Flags!

<FlagsPublic 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
-------------
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
"shapper" <mdmoura@.gmail.comwrote in message
news:1182349298.570647.201260@.w5g2000hsg.googlegro ups.com...

Quote:

Originally Posted by

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
>


On Jun 21, 2:11 pm, "Kevin Spencer" <unclechut...@.nothinks.comwrote:

Quote:

Originally Posted by

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
>
"shapper" <mdmo...@.gmail.comwrote in message
>
news:1182349298.570647.201260@.w5g2000hsg.googlegro ups.com...
>

Quote:

Originally Posted by

Hello,


>

Quote:

Originally Posted by

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


>

Quote:

Originally Posted by

<Serializable()_
Public Class Options


>

Quote:

Originally Posted by

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


>

Quote:

Originally Posted by

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


>

Quote:

Originally Posted by

' 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


>

Quote:

Originally Posted by

Can I make this?


>

Quote:

Originally Posted by

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


>

Quote:

Originally Posted by

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


>

Quote:

Originally Posted by

Thanks,
Miguel


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 <flagenum 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
Hi Miguel,

Quote:

Originally Posted by

Is this ok?


I do not see any problems.

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

0 comments:

Post a Comment