B
BobRoyAce
Let's say that I have multiple classes, representing various entities.
For example, I have Merchant, Customer, etc. Well, I have an
application where users can attach documents to many different
entities. The folder in which these documents would be stored depends
on the type of entity and, perhaps, one of the fields/properties of
the entity. So, Merchants may store their doc's under C:\Docs\Merchants
\MERCHANT_NAME, where MERCHANT_NAME is a property of a Merchant.
Customers, on the other hand, may store their doc's under C:\Docs
\Customers\CUSTOMER_NAME, where CUSTOMER_NAME is a property of a
Customer.
Well, I am creating a "generic" form that can be used to attach
documents to all of the entities that allow for this. What I need to
know how to do is create the classes such that they all have a
function, called GetAttachedDocumentsFolder, which will pass me back
the path. Then, on the form, I want to be able to call that function
regardless of the type of entity. In other words, I don't want to do
something like this:
Dim sFolder As String
Select Case Entity
Case AMerchant
Dim oMerchant As Merchant
sFolder = oMerchant.GetAttachedDocumentsFolder
Case ACustomer
Dim oCustomer As Customer
sFolder = oCustomer.GetAttachedDocumentsFolder
...
End Select
I want to just be able to do something like pass an object to the
form, let's say called oEntity, and then just be able to call
oEntity.GetAttachedDocumentsFolder. The passed in object could be any
of many different ojbect types.
How would I accomplish something like this? I am thinking that I need
to use interfaces or something...will have to look into that.
For example, I have Merchant, Customer, etc. Well, I have an
application where users can attach documents to many different
entities. The folder in which these documents would be stored depends
on the type of entity and, perhaps, one of the fields/properties of
the entity. So, Merchants may store their doc's under C:\Docs\Merchants
\MERCHANT_NAME, where MERCHANT_NAME is a property of a Merchant.
Customers, on the other hand, may store their doc's under C:\Docs
\Customers\CUSTOMER_NAME, where CUSTOMER_NAME is a property of a
Customer.
Well, I am creating a "generic" form that can be used to attach
documents to all of the entities that allow for this. What I need to
know how to do is create the classes such that they all have a
function, called GetAttachedDocumentsFolder, which will pass me back
the path. Then, on the form, I want to be able to call that function
regardless of the type of entity. In other words, I don't want to do
something like this:
Dim sFolder As String
Select Case Entity
Case AMerchant
Dim oMerchant As Merchant
sFolder = oMerchant.GetAttachedDocumentsFolder
Case ACustomer
Dim oCustomer As Customer
sFolder = oCustomer.GetAttachedDocumentsFolder
...
End Select
I want to just be able to do something like pass an object to the
form, let's say called oEntity, and then just be able to call
oEntity.GetAttachedDocumentsFolder. The passed in object could be any
of many different ojbect types.
How would I accomplish something like this? I am thinking that I need
to use interfaces or something...will have to look into that.