(NET) NET (2016)

Proxy in VB.NET

An object representing another object

Return


Provide a surrogate or placeholder for another object to control access to it. Proxy pattern provides a representative object (proxy) that controls access to another similar object.







Please download project with this source code from https://github.com/ViacheslavUKR/StandardDisignOopPattern



   1:      ' Proxy Design Pattern.
   2:      ' See description in //www.vb-net.com/ProgramTheory/Proxy.htm
   3:      Class MainApp
   4:          ' Entry point into console application.
   5:          Public Shared Sub Main()
   6:              ' Create proxy and request a service
   7:              Dim proxy As New Proxy()
   8:              proxy.Request()
   9:              ' Wait for user
  10:              Console.ReadKey()
  11:          End Sub
  12:      End Class
  13:      ' The 'Subject' abstract class
  14:      MustInherit Class Subject
  15:          Public MustOverride Sub Request()
  16:      End Class
  17:   
  18:      ' The 'RealSubject' class
  19:      Class RealSubject
  20:          Inherits Subject
  21:          Public Overrides Sub Request()
  22:              Console.WriteLine("Called RealSubject.Request()")
  23:          End Sub
  24:      End Class
  25:   
  26:      ' The 'Proxy' class
  27:      Class Proxy
  28:          Inherits Subject
  29:          Private _realSubject As RealSubject
  30:          Public Overrides Sub Request()
  31:              ' Use 'lazy initialization'
  32:              If _realSubject Is Nothing Then
  33:                  _realSubject = New RealSubject()
  34:              End If
  35:              _realSubject.Request()
  36:          End Sub
  37:      End Class




See also:
Creational Patterns Structural Patterns Behavioral Patterns

Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/ProgramTheory/Proxy.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  <