martedì 15 dicembre 2009

Vb vs C# (implemetare un interfaccia.... )

A denti stretti .. molto molto stretti ...


Questa la non troppo diversa Interfaccia.....
Public Interface IPlugin

Property PluginName() As String
Property PluginLabel() As String
Property PluginCategory() As String

Sub Execute(ByVal params As Object())

End Interface

Questa la troppo diversa Implementazione dell' Interfaccia.....

Public Class SimpleCalculator
Implements IPlugin

Private _PluginName As String = "SimpleCalculator"
Private _PluginLabel As String = "Simple Calculator"
Private _PluginCategory As String = "Commons"

Public Property PluginName() As String Implements IPlugin.PluginName
Get
Return _PluginName
End Get
Set(ByVal value As String)
_PluginName = value
End Set
End Property

Public Property PluginLabel() As String Implements IPlugin.PluginLabel
Get
Return _PluginLabel
End Get
Set(ByVal value As String)
_PluginLabel = value
End Set
End Property

Public Property PluginCategory() As String Implements IPlugin.PluginCategory
Get
Return _PluginCategory
End Get
Set(ByVal value As String)
_PluginCategory = value
End Set
End Property


Public Sub Execute(ByVal params As Object()) _
Implements IPlugin.Execute

End Sub
End Class


Io io io io ... si ci vorrebbe una bella scarica di "io io io" non è semplice intuire come si fa cosa e perchè ....

Vi siete domandati come si ottiene una classe ASTRATTA.. o UNA STATICA... no ???
bhe la seconda vi posso dire che non esiste.. o quanto meno vi serve un modulo e dichiarare in esso la classe,

STATIC pictureManager AS New PictureManager()

La prima... vi posto l'esempio che forse fa meno male....

Public MustInherit Class FactoryCore

Public iPluginList As List(Of IPlugin)

Private Sub LoadItems()

End Sub

Public MustOverride Sub CreatePlugin()


End Class

La difficoltà sta nel comprendere che si Sottointende, e non che cosa realmente si intende...

MustInherit sottointende che si "deve necessariamente "ESTENDERE QUESTA CLASSE

E' questa è una buona grammatica....

Nessun commento: