"Eugene" <Eu****@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
I meant MethodA calls MethodB with Obj1 as its parameter with
ByVal. However, MethodB is something like a plug-in and I want to
ensure the other programmers would not change Obj1 properties,
but just can read and use the data.
Two choices.
Use Interfaces to define what the Developer is allowed to do
- and make all the properties on this [particular] Interface ReadOnly.
This is probably the safest approach.
Have your class provide a "data-only" version of itself, via a
property, something like
Public Class BigClass
' Here's an updatable property that we don't want tampered with
Public Property Thingy() as Integer
Get
Return m_iThingy
End Get
Set( Value as Integer )
m_iThingy = Value
End Set
End Property
Private m_iThingy as Integer = -1
' Property to get hold of the "safe" Data Class
Public ReadOnly Property ViewData() as DataClass
Return New DataClass( Me )
End Property
' The Data class that others should be reading
Public Class DataClass
Friend Sub New( ByVal oaParent as BigClass )
m_oParent = oaParent
End Sub
' ReadOnly version of the previously updatable property
Public ReadOnly Property Thingy() As Integer
Get
Return m_oParent.Thingy
End Get
End Property
Private m_oParent as BigClass = Nothing
End Class
End Class
then, Developers should only ever write functions that use the Data Class.
HTH,
Phill W.