I just implemented the abstract factory model, but I just had a look. It is a encouragement for me to come to the Sun first.
The effect is:
There are not many codes written for each Class. Note that the VB.net syntax is different from the C # syntax. For example, the keyword overrides, inherits, and the difference in function return values, VB.net directly uses "=" to complete:
Createuser = new accessuser. The return keyword is used in the C # implementation.
In this way, the client code does not need to have specific database Metadata classes, but only needs to use the abstraction of these classes. Encapsulate the specific data access process. The client code is as follows:
Public class form1
Private sub button#click (byval sender as system. Object, byval e as system. eventargs) handles button1.click
Dim accessfactorytest as new accessfactory
Dim usertest as user
Usertest = accessfactorytest. createuser
Usertest. connectdatabase ()
End sub
Private sub button2_click (byval sender as system. Object, byval e as system. eventargs) handles button2.click
Dim sqlserverfactorytest as new sqlserverfactory
Dim sqlserverusertest as user
Sqlserverusertest = sqlserverfactorytest. createuser
Sqlserverusertest. connectdatabase ()
End sub
End Class