Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I want to create a structure where in I have a source class which has got 2 funtions: GetData() As Datatable and GetSchema() As Datatable. When this functions are called it should accordingly go to one of the interface depending on the type of file selected i.e If CSV selected then go to CSV interface class and get the data and schema reading from the selected CSV file else if ExcelFile is selected then the call to SourceClass.GetData() should go and fetch the data from the Excel Interface class.

All in all what I want to achieve is that a call to SourceClass.GetData would go and fetch the datatable by reading the appropriate file using the appropriate interface class and I dont have to pass any values into it like FileName, FilePath, FileType, HasHeaderRow, Connection String etc... as the interface class would already have all that information to get the data from...

I am quite new and thick to this and would therefore appreciate some kind of example to explain how can I achieve this....

Many Thanks.
Posted
Updated 18-Mar-10 3:17am
v2

I think what you are looking for is The factory Method Pattern[^]. there is a C# example[^] if you scroll down enough.

A note on terminology: what you are looking for is a pattern where you have different implementations of the same interface, using different details to accomplish the same abstract tasks. not two different interfaces...
 
Share this answer
 
Just went over my head :( :( Can you please elaborate in vb.net language as I have no idea about c# :( :(
 
Share this answer
 
This link[^] has a vb example.
 
Share this answer
 
The links not working :( saying that can I please ask you a favour to post me some code here that would link to what I want to achieve so I can understand it a lot better?

Thanks.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900